Regular Solution Gibbs Excess Model (thermo.regular_solution)¶
This module contains a class RegularSolution for performing activity coefficient
calculations with the regular solution model.
For reporting bugs, adding feature requests, or submitting pull requests, please use the GitHub issue tracker.
Regular Solution Class¶
- class thermo.regular_solution.RegularSolution(*, xs, Vs, SPs, T=298.15, lambda_coeffs=None)[source]¶
Bases:
GibbsExcessClass for representing an a liquid with excess gibbs energy represented by the Regular Solution model. This model is not temperature dependent and has limited predictive ability, but can be used without interaction parameters. This model is described in [1].
In the above equation, represents the solubility parameters, and is the interaction coefficient between m and n. The model makes no assumption about the symmetry of this parameter.
- Parameters:
- T
float Temperature, [K]
- xs
list[float] Mole fractions, [-]
- Vs
list[float] Molar volumes of each compond at a reference temperature (often 298.15 K), [m^3/mol]
- SPs
list[float] Solubility parameters of each compound; normally at a reference temperature of 298.15 K, [Pa^0.5]
- lambda_coeffs
list[list[float]],optional Optional interaction parameters, [-]
- T
- Attributes:
- T
float Temperature, [K]
- xs
list[float] Mole fractions, [-]
- Vs
list[float] Molar volumes of each compond at a reference temperature (often 298.15 K), [K]
- SPs
list[float] Solubility parameters of each compound; normally at a reference temperature of 298.15 K, [Pa^0.5]
- lambda_coeffs
list[list[float]] Interaction parameters, [-]
- T
Methods
GE()Calculate and return the excess Gibbs energy of a liquid phase using the regular solution model.
d2GE_dT2()Calculate and return the second temperature derivative of excess Gibbs energy of a liquid phas.
Calculate and return the temperature derivative of mole fraction derivatives of excess Gibbs energy.
Calculate and return the second mole fraction derivatives of excess Gibbs energy of a liquid phase using the regular solution model.
d3GE_dT3()Calculate and return the third temperature derivative of excess Gibbs energy of a liquid phase.
Calculate and return the third mole fraction derivatives of excess Gibbs energy.
dGE_dT()Calculate and return the temperature derivative of excess Gibbs energy of a liquid phase.
dGE_dxs()Calculate and return the mole fraction derivatives of excess Gibbs energy of a liquid phase using the regular solution model.
to_T_xs(T, xs)Method to construct a new
RegularSolutioninstance at temperature T, and mole fractions xs with the same parameters as the existing object.Notes
In addition to the methods presented here, the methods of its base class
thermo.activity.GibbsExcessare available as well.Additional equations of note are as follows.
Note that some sources use the convention of a negation for the calculation of A_{mn}.
Coefficients from models in that form can be used with this model simply by negating the k_{mn} parameters:
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]Gmehling, Jürgen, Michael Kleiber, Bärbel Kolbe, and Jürgen Rarey. Chemical Thermodynamics for Process Simulation. John Wiley & Sons, 2019.
[3]Elliott, J., and Carl Lira. Introductory Chemical Engineering Thermodynamics. 2nd edition. Upper Saddle River, NJ: Prentice Hall, 2012.
[4]Kooijman, Harry A., and Ross Taylor. The ChemSep Book. Books on Demand Norderstedt, Germany, 2000.
Examples
Example 1
From [2], calculate the activity coefficients at infinite dilution for the system benzene-cyclohexane at 253.15 K using the regular solution model (example 5.20, with unit conversion in-line):
>>> from scipy.constants import calorie >>> GE = RegularSolution(T=353.15, xs=[.5, .5], Vs=[89E-6, 109E-6], SPs=[9.2*(calorie*1e6)**0.5, 8.2*(calorie*1e6)**0.5]) >>> GE.gammas_infinite_dilution() [1.1352128394, 1.16803058378]
This matches the solution given of [1.135, 1.168].
Example 2
Benzene and cyclohexane calculation from [3], without interaction parameters.
>>> GE = RegularSolution(T=353, xs=[0.01, 0.99], Vs=[8.90e-05, 1.09e-04], SPs=[9.2*(calorie/1e-6)**0.5, 8.2*(calorie/1e-6)**0.5]) >>> GE.gammas() [1.1329295, 1.00001039]
Example 3
Another common model is the Flory-Huggins model. This isn’t implemented as a separate model, but it is possible to modify the activity coefficient results of
RegularSolutionto obtain the activity coefficients from the Flory-Huggins model anyway. ChemSep [4] implements the Flory-Huggins model and calls it the regular solution model, so results can’t be compared with ChemSep except when making the following manual solution. The example below uses parameters from ChemSep for ethanol and water.>>> from math import log >>> GE = RegularSolution(T=298.15, xs=[0.5, 0.5], Vs=[0.05868e-3, 0.01807e-3], SPs=[26140.0, 47860.0]) >>> GE.gammas() # Regular solution activity coefficients [1.8570955489, 7.464567232] >>> lngammass = [log(g) for g in GE.gammas()] >>> thetas = [GE.Vs[i]/sum(GE.xs[i]*GE.Vs[i] for i in range(GE.N)) for i in range(GE.N)] >>> gammas_flory_huggins = [exp(lngammass[i] + log(thetas[i]) + 1 - thetas[i]) for i in range(GE.N)] >>> gammas_flory_huggins [1.672945693, 5.9663471]
This matches the values calculated from ChemSep exactly.
- GE()[source]¶
Calculate and return the excess Gibbs energy of a liquid phase using the regular solution model.
- Returns:
- GE
float Excess Gibbs energy, [J/mol]
- GE
- d2GE_dT2()[source]¶
Calculate and return the second temperature derivative of excess Gibbs energy of a liquid phas.
- 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.
- d2GE_dxixjs()[source]¶
Calculate and return the second mole fraction derivatives of excess Gibbs energy of a liquid phase using the regular solution model.
- d3GE_dT3()[source]¶
Calculate and return the third temperature derivative of excess Gibbs energy of a liquid phase.
- 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.
- dGE_dT()[source]¶
Calculate and return the temperature derivative of excess Gibbs energy of a liquid phase.
- Returns:
- dGE_dT
float First temperature derivative of excess Gibbs energy, [J/(mol*K)]
- dGE_dT
- dGE_dxs()[source]¶
Calculate and return the mole fraction derivatives of excess Gibbs energy of a liquid phase using the regular solution model.
- to_T_xs(T, xs)[source]¶
Method to construct a new
RegularSolutioninstance at temperature T, and mole fractions xs with the same parameters as the existing object.- Parameters:
- Returns:
- obj
RegularSolution New
RegularSolutionobject at the specified conditions [-]
- obj
Flory Huggins Class¶
- class thermo.regular_solution.FloryHuggins(*, xs, Vs, SPs, T=298.15, lambda_coeffs=None)[source]¶
Bases:
GibbsExcessClass for representing a liquid with excess Gibbs energy represented by the Flory-Huggins model. This model extends the Regular Solution model by adding entropic contributions from the different sizes of molecules.
The model can also be written as an addition to the Regular Solution model as follows:
- Parameters:
- T
float Temperature, [K]
- xs
list[float] Mole fractions, [-]
- Vs
list[float] Molar volumes of each component at a reference temperature (often 298.15 K), [m^3/mol]
- SPs
list[float] Solubility parameters of each compound; normally at a reference temperature of 298.15 K, [Pa^0.5]
- lambda_coeffs
list[list[float]],optional Optional interaction parameters, [-]
- T
- Attributes:
- T
float Temperature, [K]
- xs
list[float] Mole fractions, [-]
- Vs
list[float] Molar volumes of each component at a reference temperature (often 298.15 K), [K]
- SPs
list[float] Solubility parameters of each compound; normally at a reference temperature of 298.15 K, [Pa^0.5]
- lambda_coeffs
list[list[float]] Interaction parameters, [-]
- T
Methods
GE()Calculate and return the excess Gibbs energy of a liquid phase using the Flory-Huggins model.
d2GE_dT2()Calculate and return the second temperature derivative of excess Gibbs energy of a liquid phas.
Calculate and return the temperature derivative of mole fraction derivatives of excess Gibbs energy.
Calculate and return the second mole fraction derivatives of excess Gibbs energy of a liquid phase using the regular solution model.
d3GE_dT3()Calculate and return the third temperature derivative of excess Gibbs energy of a liquid phase.
Calculate and return the third mole fraction derivatives of excess Gibbs energy.
dGE_dT()Calculate and return the temperature derivative of excess Gibbs energy of a liquid phase.
dGE_dxs()Calculate and return the mole fraction derivatives of excess Gibbs energy of a liquid phase using the regular solution model.
to_T_xs(T, xs)Method to construct a new
RegularSolutioninstance at temperature T, and mole fractions xs with the same parameters as the existing object.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]Kooijman, Harry A., and Ross Taylor. The ChemSep Book. Books on Demand Norderstedt, Germany, 2000.
Examples
The example below uses parameters from ChemSep for ethanol and water.
>>> GE = FloryHuggins(T=298.15, xs=[0.5, 0.5], Vs=[0.05868e-3, 0.01807e-3], SPs=[26140.0, 47860.0]) >>> GE.gammas() [1.672945693, 5.9663471]
This matches the values calculated from ChemSep exactly.
- GE()[source]¶
Calculate and return the excess Gibbs energy of a liquid phase using the Flory-Huggins model.
- Returns:
- GE
float Excess Gibbs energy, [J/mol]
- GE
- d2GE_dT2()¶
Calculate and return the second temperature derivative of excess Gibbs energy of a liquid phas.
- 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.
- d2GE_dxixjs()[source]¶
Calculate and return the second mole fraction derivatives of excess Gibbs energy of a liquid phase using the regular solution model.
For brevity, the equation is presented only as an addition to the regular solution equation:
- d3GE_dT3()¶
Calculate and return the third temperature derivative of excess Gibbs energy of a liquid phase.
- 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.
For brevity, the equation is presented only as an addition to the regular solution equation:
- dGE_dT()[source]¶
Calculate and return the temperature derivative of excess Gibbs energy of a liquid phase.
- Returns:
- dGE_dT
float First temperature derivative of excess Gibbs energy, [J/(mol*K)]
- dGE_dT
- dGE_dxs()[source]¶
Calculate and return the mole fraction derivatives of excess Gibbs energy of a liquid phase using the regular solution model.
Or as an addition to the regular solution equation:
- to_T_xs(T, xs)¶
Method to construct a new
RegularSolutioninstance at temperature T, and mole fractions xs with the same parameters as the existing object.- Parameters:
- Returns:
- obj
RegularSolution New
RegularSolutionobject at the specified conditions [-]
- obj
Hansen Class¶
- class thermo.regular_solution.Hansen(*, xs, Vs, delta_d, delta_p, delta_h, T=298.15, alpha=1.0)[source]¶
Bases:
GibbsExcessClass for representing a liquid with excess Gibbs energy represented by the Hansen model. This model extends the Flory-Huggins approach by considering three different types of molecular interactions: dispersive, polar, and hydrogen bonding.
The excess Gibbs energy is calculated using:
Where the interaction parameters A_{mn} are calculated using Hansen parameters:
The alpha term can be taken as 1, adjusted to fit a particular data set, or set to 0.6 as recommended in [1].
- Parameters:
- T
float Temperature, [K]
- xs
list[float] Mole fractions, [-]
- Vs
list[float] Molar volumes of each component at a reference temperature (often 298.15 K), [m^3/mol]
- delta_d
list[float] Hansen dispersive parameters for each component, [Pa^0.5]
- delta_p
list[float] Hansen polar parameters for each component, [Pa^0.5]
- delta_h
list[float] Hansen hydrogen bonding parameters for each component, [Pa^0.5]
- alpha
float,optional Optional scaling factor for the interaction terms, defaults to 1.0, [-]
- T
Methods
GE()Calculate and return the excess Gibbs energy of a liquid phase using the Flory-Huggins model.
d2GE_dT2()Calculate and return the second temperature derivative of excess Gibbs energy of a liquid phas.
Calculate and return the temperature derivative of mole fraction derivatives of excess Gibbs energy.
d3GE_dT3()Calculate and return the third temperature derivative of excess Gibbs energy of a liquid phase.
dGE_dT()Calculate and return the temperature derivative of excess Gibbs energy of a liquid phase.
dGE_dxs()Calculate and return the mole fraction derivatives of excess Gibbs energy of a liquid phase using the regular solution model.
to_T_xs(T, xs)Method to construct a new
Hanseninstance at temperature T, and mole fractions xs with the same parameters as the existing object.d2GE_dxixjs
Notes
The Hansen model uses the same mathematical framework as the Flory-Huggins model but replaces the single solubility parameter with three Hansen parameters that better account for different types of molecular interactions. The excess Gibbs energy derivatives follow the same form as the Flory-Huggins model with the modified interaction parameters.
The delta and Vs terms can be specified in units of cm^3/mol and MPa^0.5 and the
References
[1]Lindvig, Thomas, Michael L Michelsen, and Georgios M Kontogeorgis. “A Flory-Huggins Model Based on the Hansen Solubility Parameters.” Fluid Phase Equilibria 203, no. 1 (December 1, 2002): 247-60. https://doi.org/10.1016/S0378-3812(02)00184-X.
[2] (1,2)Brouwer, Thomas, and Boelo Schuur. “Model Performances Evaluated for Infinite Dilution Activity Coefficients Prediction at 298.15 K.” Industrial & Engineering Chemistry Research 58, no. 20 (May 22, 2019): 8903-14. https://doi.org/10.1021/acs.iecr.9b00727.
[3]Hansen, Charles M. Hansen Solubility Parameters: A User’s Handbook. CRC press, 2007.
Examples
[2] presents a number of examplese in their supporting material. No specific concentration was specified for what mole fraction was used to evaluate infinite dilution coefficients, however 2-3% seems to fit the data points provided in many cases. The 0.6 alpha also seems to have been used in their paper.
1-nitropropane as solvent, 2-methylbutane as solute from [2] - expected infinite dilution activity coefficient of 3.5:
>>> xs = [.97, 0.03] >>> Vs = [89, 115.2] >>> Vs = [Vi*1e-6 for Vi in Vs] >>> delta_d = [16.6, 14.5] >>> delta_p = [12.3, 0.0] >>> delta_h = [5.5, 0.0] >>> delta_factor = 1000 >>> delta_d = [v*delta_factor for v in delta_d] >>> delta_p = [v*delta_factor for v in delta_p] >>> delta_h = [v*delta_factor for v in delta_h] >>> GE = Hansen(T=298.15, xs=xs, Vs=Vs, delta_d=delta_d, delta_p=delta_p, delta_h=delta_h, alpha=0.6) >>> GE.gammas()[1] 3.48957861 >>> GE.gammas_infinite_dilution()[1] 3.8654190 >>> GE.GE() 96.67
The conversion factors can also be omitted as they cancel out:
>>> GE = Hansen(T=298.15, xs=[.97, 0.03], Vs=[89, 115.2], delta_d=[16.6, 14.5], delta_p=[12.3, 0.0], delta_h=[5.5, 0.0], alpha=0.6) >>> GE.GE() 96.67
- GE()¶
Calculate and return the excess Gibbs energy of a liquid phase using the Flory-Huggins model.
- Returns:
- GE
float Excess Gibbs energy, [J/mol]
- GE
- d2GE_dT2()¶
Calculate and return the second temperature derivative of excess Gibbs energy of a liquid phas.
- Returns:
- d2GE_dT2
float Second temperature derivative of excess Gibbs energy, [J/(mol*K^2)]
- d2GE_dT2
- d2GE_dTdxs()¶
Calculate and return the temperature derivative of mole fraction derivatives of excess Gibbs energy.
- d2GE_dxixjs(derive_attr='GE')¶
- d3GE_dT3()¶
Calculate and return the third temperature derivative of excess Gibbs energy of a liquid phase.
- Returns:
- d3GE_dT3
float Third temperature derivative of excess Gibbs energy, [J/(mol*K^3)]
- d3GE_dT3
- dGE_dT()¶
Calculate and return the temperature derivative of excess Gibbs energy of a liquid phase.
- Returns:
- dGE_dT
float First temperature derivative of excess Gibbs energy, [J/(mol*K)]
- dGE_dT
- dGE_dxs()¶
Calculate and return the mole fraction derivatives of excess Gibbs energy of a liquid phase using the regular solution model.
Or as an addition to the regular solution equation:
Regular Solution Regression Calculations¶
- thermo.regular_solution.regular_solution_gammas_binaries(xs, Vs, SPs, Ts, lambda12, lambda21, gammas=None)[source]¶
Calculates activity coefficients with the regular solution model at fixed lambda values for a binary system at a series of mole fractions at specified temperatures. 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), … size pts*2 [-]
- Vs
list[float] Molar volumes of each of the two components, [m^3/mol]
- SPs
list[float] Solubility parameters of each of the two components, [Pa^0.5]
- Ts
flist[float] Temperatures of each composition point; half the length of xs, [K]
- 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:
Examples
>>> regular_solution_gammas_binaries([.1, .9, 0.3, 0.7, .85, .15], Vs=[7.421e-05, 8.068e-05], SPs=[19570.2, 18864.7], Ts=[300.0, 400.0, 500.0], lambda12=0.1759, lambda21=0.7991) [6818.90697, 1.105437, 62.6628, 2.01184, 1.181434, 137.6232]