Virial Coefficients (chemicals.virial)¶
This module contains four estimation methods for second B virial coefficients, two utility covnersions for when only B is considered, and two methods to calculate Z from higher order virial expansions.
For reporting bugs, adding feature requests, or submitting pull requests, please use the GitHub issue tracker.
Utilities¶
- chemicals.virial.B_to_Z(B, T, P)[source]¶
Calculates the compressibility factor of a gas, given its second virial coefficient.
- Parameters
- Returns
- Z
float
Compressibility factor, [-]
- Z
Notes
Other forms of the virial coefficient exist.
References
- 1
Poling, Bruce E. The Properties of Gases and Liquids. 5th edition. New York: McGraw-Hill Professional, 2000.
Examples
>>> B_to_Z(-0.0015, 300, 1E5) 0.939863822478637
- chemicals.virial.B_from_Z(Z, T, P)[source]¶
Calculates the second virial coefficient of a pure species, given the compressibility factor of the gas.
- Parameters
- Returns
- B
float
Second virial coefficient, [m^3/mol]
- B
Notes
Other forms of the virial coefficient exist.
References
- 1
Poling, Bruce E. The Properties of Gases and Liquids. 5th edition. New York: McGraw-Hill Professional, 2000.
Examples
>>> B_from_Z(0.94, 300, 1E5) -0.0014966032712675846
- chemicals.virial.Z_from_virial_density_form(T, P, coeffs=None)[source]¶
Calculates the compressibility factor of a gas given its temperature, pressure, and molar density-form virial coefficients. Any number of coefficients is supported.
- Parameters
- T
float
Temperature, [K]
- P
float
Pressure, [Pa]
- coeffs
list
[float
],optional
Sequence of virial coefficients [m³/mol^n], where n is the position: - First coefficient (n=1): Second virial coefficient B [m³/mol] - Second coefficient (n=2): Third virial coefficient C [m³/mol²] - Third coefficient (n=3): Fourth virial coefficient D [m³/mol³]
- T
- Returns
- Z
float
Compressibility factor at T, P, and with given virial coefficients, [-]
- Z
Notes
For use with B or with B and C or with B and C and D, optimized equations are used to obtain the compressibility factor directly. If more coefficients are provided, uses numpy’s roots function to solve this equation. This takes substantially longer as the solution is numerical.
If no virial coefficients are given, returns 1, as per the ideal gas law.
The units of each virial coefficient are as follows, where for B, n=1, and C, n=2, and so on.
References
- 1
Prausnitz, John M., Rudiger N. Lichtenthaler, and Edmundo Gomes de Azevedo. Molecular Thermodynamics of Fluid-Phase Equilibria. 3rd edition. Upper Saddle River, N.J: Prentice Hall, 1998.
- 2
Walas, Stanley M. Phase Equilibria in Chemical Engineering. Butterworth-Heinemann, 1985.
Examples
>>> Z_from_virial_density_form(300, 122057.233762653, [1E-4, 1E-5, 1E-6, 1E-7]) 1.28434940526
- chemicals.virial.Z_from_virial_pressure_form(P, coeffs=None)[source]¶
Calculates the compressibility factor of a gas given its pressure, and pressure-form virial coefficients. Any number of coefficients is supported.
- Parameters
- P
float
Pressure, [Pa]
- coeffs
list
[float
],optional
List of pressure-form virial coefficients [1/Pa^n], where n is the index+1: coeffs[0]: Second virial coefficient B’ [1/Pa] coeffs[1]: Third virial coefficient C’ [1/Pa²] coeffs[2]: Fourth virial coefficient D’ [1/Pa³] If None, returns ideal gas compressibility of 1.
- P
- Returns
- Z
float
Compressibility factor at P, and with given virial coefficients, [-]
- Z
Notes
Note that although this function does not require a temperature input, it is still dependent on it because the coefficients themselves normally are regressed in terms of temperature.
The use of this form is less common than the density form. Its coefficients are normally indicated with the “’” suffix.
If no virial coefficients are given, returns 1, as per the ideal gas law.
The units of each virial coefficient are as follows, where for B, n=1, and C, n=2, and so on.
References
- 1
Prausnitz, John M., Rudiger N. Lichtenthaler, and Edmundo Gomes de Azevedo. Molecular Thermodynamics of Fluid-Phase Equilibria. 3rd edition. Upper Saddle River, N.J: Prentice Hall, 1998.
- 2
Walas, Stanley M. Phase Equilibria in Chemical Engineering. Butterworth-Heinemann, 1985.
Examples
>>> Z_from_virial_pressure_form(102919.99946855308, [4.032286555169439e-09, 1.6197059494442215e-13, 6.483855042486911e-19]) 1.00283753944
- chemicals.virial.BVirial_mixture(zs, Bijs)[source]¶
Calculate the B second virial coefficient from a matrix of virial cross-coefficients. The diagonal is virial coefficients of the pure components.
- Parameters
- Returns
- B
float
Second virial coefficient in density form [m^3/mol]
- B
References
- 1
Poling, Bruce E. The Properties of Gases and Liquids. 5th edition. New York: McGraw-Hill Professional, 2000.
Examples
>>> Bijs = [[-6.24e-06, -2.013e-05, -3.9e-05], [-2.01e-05, -4.391e-05, -6.46e-05], [-3.99e-05, -6.46e-05, -0.00012]] >>> zs = [.5, .3, .2] >>> BVirial_mixture(zs=zs, Bijs=Bijs) -3.19884e-05
- chemicals.virial.dBVirial_mixture_dzs(zs, Bijs, dB_dzs=None)[source]¶
Calculate first mole fraction derivative of the B second virial coefficient from a matrix of virial cross-coefficients.
- Parameters
- Returns
Examples
>>> Bijs = [[-6.24e-06, -2.013e-05, -3.9e-05], [-2.01e-05, -4.391e-05, -6.46e-05], [-3.99e-05, -6.46e-05, -0.00012]] >>> zs = [.5, .3, .2] >>> dBVirial_mixture_dzs(zs=zs, Bijs=Bijs) [-3.4089e-05, -7.2301e-05, -0.00012621]
- chemicals.virial.d2BVirial_mixture_dzizjs(zs, Bijs, d2B_dzizjs=None)[source]¶
Calculate second mole fraction derivative of the B second virial coefficient from a matrix of virial cross-coefficients.
- Parameters
- Returns
Examples
>>> Bijs = [[-6.24e-06, -2.013e-05, -3.9e-05], [-2.01e-05, -4.391e-05, -6.46e-05], [-3.99e-05, -6.46e-05, -0.00012]] >>> zs = [.5, .3, .2] >>> d2BVirial_mixture_dzizjs(zs=zs, Bijs=Bijs) [[-1.248e-05, -4.023e-05, -7.89e-05], [-4.023e-05, -8.782e-05, -0.0001292], [-7.89e-05, -0.0001292, -0.00024]]
- chemicals.virial.d3BVirial_mixture_dzizjzks(zs, Bijs, d3B_dzizjzks=None)[source]¶
Calculate third mole fraction derivative of the B third virial coefficient from a matrix of virial cross-coefficients.
- Parameters
- Returns
Examples
>>> Bijs = [[-6.24e-06, -2.013e-05, -3.9e-05], [-2.01e-05, -4.391e-05, -6.46e-05], [-3.99e-05, -6.46e-05, -0.00012]] >>> zs = [.5, .3, .2] >>> d3BVirial_mixture_dzizjzks(zs=zs, Bijs=Bijs) [[[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]], [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]], [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]]
- chemicals.virial.CVirial_mixture_Orentlicher_Prausnitz(zs, Cijs)[source]¶
Calculate the C third virial coefficient from a matrix of virial cross-coefficients. The diagonal is virial coefficients of the pure components.
- Parameters
- Returns
- C
float
Third virial coefficient in density form [m^6/mol^2]
- C
References
- 1
Poling, Bruce E. The Properties of Gases and Liquids. 5th edition. New York: McGraw-Hill Professional, 2000.
Examples
>>> Cijs = [[1.46e-09, 1.831e-09, 2.12e-09], [1.831e-09, 2.46e-09, 2.996e-09], [2.12e-09, 2.996e-09, 4.927e-09]] >>> zs = [.5, .3, .2] >>> CVirial_mixture_Orentlicher_Prausnitz(zs, Cijs) 2.0790440095e-09
- chemicals.virial.dCVirial_mixture_dT_Orentlicher_Prausnitz(zs, Cijs, dCij_dTs)[source]¶
Calculate the first temperature derivative of the C third virial coefficient from matrices of virial cross-coefficients and their first temperature derivatives.
- Parameters
- Returns
- dC_dT
float
First temperature derivative of third virial coefficient in density form [m^6/mol^2/K]
- dC_dT
References
- 1
Poling, Bruce E. The Properties of Gases and Liquids. 5th edition. New York: McGraw-Hill Professional, 2000.
Examples
>>> Cijs = [[1.46e-09, 1.831e-09, 2.12e-09], [1.831e-09, 2.46e-09, 2.996e-09], [2.12e-09, 2.996e-09, 4.927e-09]] >>> dCij_dTs = [[-2.212e-12, -4.137e-12, -1.079e-11], [-4.137e-12, -7.669e-12, -1.809e-11], [-1.079e-11, -1.809e-11, -2.010e-11]] >>> zs = [.5, .3, .2] >>> dCVirial_mixture_dT_Orentlicher_Prausnitz(zs, Cijs, dCij_dTs) -7.2751517e-12
- chemicals.virial.d2CVirial_mixture_dT2_Orentlicher_Prausnitz(zs, Cijs, dCij_dTs, d2Cij_dT2s)[source]¶
Calculate the second temperature derivative of the C third virial coefficient from matrices of virial cross-coefficients and their first and second temperature derivatives.
- Parameters
- zs
list
[float
] Mole fractions of each species, [-]
- Cijs
list
[list
[float
]] Third virial binary interaction coefficients in density form [m^6/mol^2]
- dCij_dTs
list
[list
[float
]] First temperature derivative of third virial binary interaction coefficients in density form [m^6/mol^2/K]
- d2Cij_dT2s
list
[list
[float
]] Second temperature derivative of third virial binary interaction coefficients in density form [m^6/mol^2/K^2]
- zs
- Returns
- d2C_dT2
float
Second temperature derivative of third virial coefficient in density form [m^6/mol^2/K^2]
- d2C_dT2
References
- 1
Poling, Bruce E. The Properties of Gases and Liquids. 5th edition. New York: McGraw-Hill Professional, 2000.
Examples
>>> Cijs = [[1.46e-09, 1.831e-09, 2.12e-09], [1.831e-09, 2.46e-09, 2.996e-09], [2.12e-09, 2.996e-09, 4.927e-09]] >>> dCij_dTs = [[-2.212e-12, -4.137e-12, -1.079e-11], [-4.137e-12, -7.669e-12, -1.809e-11], [-1.079e-11, -1.809e-11, -2.010e-11]] >>> d2Cij_dT2s = [[ 2.6469e-14, 5.0512e-14, 1.1509e-13], [ 5.0512e-14, 9.3272e-14, 1.7836e-13], [ 1.1509e-13, 1.7836e-13, -1.4906e-13]] >>> zs = [.5, .3, .2] >>> d2CVirial_mixture_dT2_Orentlicher_Prausnitz(zs, Cijs, dCij_dTs, d2Cij_dT2s) 6.7237107787e-14
- chemicals.virial.d3CVirial_mixture_dT3_Orentlicher_Prausnitz(zs, Cijs, dCij_dTs, d2Cij_dT2s, d3Cij_dT3s)[source]¶
Calculate the third temperature derivative of the C third virial coefficient from matrices of virial cross-coefficients and their first, second, and third temperature derivatives.
The expression is quite lengthy and not shown here [1].
- Parameters
- zs
list
[float
] Mole fractions of each species, [-]
- Cijs
list
[list
[float
]] Third virial binary interaction coefficients in density form [m^6/mol^2]
- dCij_dTs
list
[list
[float
]] First temperature derivative of third virial binary interaction coefficients in density form [m^6/mol^2/K]
- d2Cij_dT2s
list
[list
[float
]] Second temperature derivative of third virial binary interaction coefficients in density form [m^6/mol^2/K^2]
- d3Cij_dT3s
list
[list
[float
]] Third temperature derivative of third virial binary interaction coefficients in density form [m^6/mol^2/K^2^2]
- zs
- Returns
- d3C_dT3
float
Third temperature derivative of third virial coefficient in density form [m^6/mol^2/K^3]
- d3C_dT3
References
- 1
Poling, Bruce E. The Properties of Gases and Liquids. 5th edition. New York: McGraw-Hill Professional, 2000.
Examples
>>> Cijs = [[1.46e-09, 1.831e-09, 2.12e-09], [1.831e-09, 2.46e-09, 2.996e-09], [2.12e-09, 2.996e-09, 4.927e-09]] >>> dCij_dTs = [[-2.212e-12, -4.137e-12, -1.079e-11], [-4.137e-12, -7.669e-12, -1.809e-11], [-1.079e-11, -1.809e-11, -2.010e-11]] >>> d2Cij_dT2s = [[ 2.6469e-14, 5.0512e-14, 1.1509e-13], [ 5.0512e-14, 9.3272e-14, 1.7836e-13], [ 1.1509e-13, 1.7836e-13, -1.4906e-13]] >>> d3Cij_dT3s = [[-4.2300e-16, -7.9727e-16, -1.6962e-15], [-7.9727e-16, -1.3826e-15, -1.4525e-15], [-1.6962e-15, -1.4525e-15, 1.9786e-14]] >>> zs = [.5, .3, .2] >>> d3CVirial_mixture_dT3_Orentlicher_Prausnitz(zs, Cijs, dCij_dTs, d2Cij_dT2s, d3Cij_dT3s) -3.7358368e-16
- chemicals.virial.dCVirial_mixture_Orentlicher_Prausnitz_dzs(zs, Cijs, dCs=None)[source]¶
Calculate the first mole fraction derivatives of the C third virial coefficient from a matrix of virial cross-coefficients.
- Parameters
- Returns
Notes
This equation can be derived with SymPy, as follows
>>> from sympy import * >>> i, j, k, m, n, o = symbols("i, j, k, m, n, o", cls=Idx) >>> zs = IndexedBase('zs') >>> Cs = IndexedBase('Cs') >>> nc = symbols('nc') >>> C_expr = Sum(zs[i]*zs[j]*zs[k]*cbrt(Cs[i,j]*Cs[i,k]*Cs[j,k]),[i,0,nc],[j,0,nc],[k,0,nc]) >>> diff(C_expr, zs[m]) Sum((Cs[i, j]*Cs[i, k]*Cs[j, k])**(1/3)*KroneckerDelta(i, m)*zs[j]*zs[k] + (Cs[i, j]*Cs[i, k]*Cs[j, k])**(1/3)*KroneckerDelta(j, m)*zs[i]*zs[k] + (Cs[i, j]*Cs[i, k]*Cs[j, k])**(1/3)*KroneckerDelta(k, m)*zs[i]*zs[j], (i, 0, nc), (j, 0, nc), (k, 0, nc))
Examples
>>> Cijs = [[1.46e-09, 1.831e-09, 2.12e-09], [1.831e-09, 2.46e-09, 2.996e-09], [2.12e-09, 2.996e-09, 4.927e-09]] >>> zs = [.5, .3, .2] >>> dCVirial_mixture_Orentlicher_Prausnitz_dzs(zs, Cijs) [5.44450470e-09, 6.54968776e-09, 7.74986672e-09]
- chemicals.virial.d2CVirial_mixture_Orentlicher_Prausnitz_dzizjs(zs, Cijs, d2Cs=None)[source]¶
Calculate the second mole fraction derivatives of the C third virial coefficient from a matrix of virial cross-coefficients.
- Parameters
- Returns
Notes
This equation can be derived with SymPy, as follows
>>> from sympy import * >>> i, j, k, m, n, o = symbols("i, j, k, m, n, o", cls=Idx) >>> zs = IndexedBase('zs') >>> Cs = IndexedBase('Cs') >>> nc = symbols('nc') >>> C_expr = Sum(zs[i]*zs[j]*zs[k]*cbrt(Cs[i,j]*Cs[i,k]*Cs[j,k]),[i,0,nc],[j,0,nc],[k,0,nc]) >>> diff(C_expr, zs[m], zs[n]) Sum((Cs[i, j]*Cs[i, k]*Cs[j, k])**(1/3)*(KroneckerDelta(i, m)*KroneckerDelta(j, n)*zs[k] + KroneckerDelta(i, m)*KroneckerDelta(k, n)*zs[j] + KroneckerDelta(i, n)*KroneckerDelta(j, m)*zs[k] + KroneckerDelta(i, n)*KroneckerDelta(k, m)*zs[j] + KroneckerDelta(j, m)*KroneckerDelta(k, n)*zs[i] + KroneckerDelta(j, n)*KroneckerDelta(k, m)*zs[i]), (i, 0, nc), (j, 0, nc), (k, 0, nc))
Examples
>>> Cijs = [[1.46e-09, 1.831e-09, 2.12e-09], [1.831e-09, 2.46e-09, 2.996e-09], [2.12e-09, 2.996e-09, 4.927e-09]] >>> zs = [.5, .3, .2] >>> d2CVirial_mixture_Orentlicher_Prausnitz_dzizjs(zs, Cijs) [[9.6827886655e-09, 1.1449146725e-08, 1.3064355337e-08], [1.1449146725e-08, 1.38557674294e-08, 1.60903596751e-08], [1.3064355337e-08, 1.60903596751e-08, 2.0702239403e-08]]
- chemicals.virial.d3CVirial_mixture_Orentlicher_Prausnitz_dzizjzks(zs, Cijs, d3Cs=None)[source]¶
Calculate the third mole fraction derivatives of the C third virial coefficient from a matrix of virial cross-coefficients.
- Parameters
- Returns
Notes
This equation can be derived with SymPy, as follows
>>> from sympy import * >>> i, j, k, m, n, o = symbols("i, j, k, m, n, o", cls=Idx) >>> zs = IndexedBase('zs') >>> Cs = IndexedBase('Cs') >>> nc = symbols('nc') >>> C_expr = Sum(zs[i]*zs[j]*zs[k]*cbrt(Cs[i,j]*Cs[i,k]*Cs[j,k]),[i,0,nc],[j,0,nc],[k,0,nc]) >>> diff(C_expr, zs[m], zs[n], zs[o]) Sum((Cs[i, j]*Cs[i, k]*Cs[j, k])**(1/3)*(KroneckerDelta(i, m)*KroneckerDelta(j, n)*KroneckerDelta(k, o) + KroneckerDelta(i, m)*KroneckerDelta(j, o)*KroneckerDelta(k, n) + KroneckerDelta(i, n)*KroneckerDelta(j, m)*KroneckerDelta(k, o) + KroneckerDelta(i, n)*KroneckerDelta(j, o)*KroneckerDelta(k, m) + KroneckerDelta(i, o)*KroneckerDelta(j, m)*KroneckerDelta(k, n) + KroneckerDelta(i, o)*KroneckerDelta(j, n)*KroneckerDelta(k, m)), (i, 0, nc), (j, 0, nc), (k, 0, nc))
Examples
>>> Cijs = [[1.46e-09, 1.831e-09, 2.12e-09], [1.831e-09, 2.46e-09, 2.996e-09], [2.12e-09, 2.996e-09, 4.927e-09]] >>> zs = [.5, .3, .2] >>> d3CVirial_mixture_Orentlicher_Prausnitz_dzizjzks(zs, Cijs) [[[8.760000000e-09, 1.0187346981e-08, 1.12329228549e-08], [1.01873469818e-08, 1.21223973593e-08, 1.35937701316e-08], [1.12329228549e-08, 1.35937701316e-08, 1.68488143533e-08]], [[1.01873469818e-08, 1.21223973593e-08, 1.35937701316e-08], [1.2122397359e-08, 1.47600000000e-08, 1.68328437491e-08], [1.35937701316e-08, 1.68328437491e-08, 2.12181074230e-08]], [[1.12329228549e-08, 1.35937701316e-08, 1.68488143533e-08], [1.35937701316e-08, 1.68328437491e-08, 2.12181074230e-08], [1.68488143533e-08, 2.12181074230e-08, 2.9562000000e-08]]]
- chemicals.virial.d2CVirial_mixture_Orentlicher_Prausnitz_dTdzs(zs, Cijs, dCij_dTs, d2C_dTdzs=None)[source]¶
Calculate the first mole fraction derivatives of the C third virial coefficient from a matrix of virial cross-coefficients.
- Parameters
- zs
list
[float
] Mole fractions of each species, [-]
- Cijs
list
[list
[float
]] Third virial binary interaction coefficients in density form [m^6/mol^2]
- dCij_dTs
list
[list
[float
]] First temperature derivative of third virial binary interaction coefficients in density form [m^6/mol^2/K]
- d2C_dTdzs
list
[float
],optional
Array for second derivatives of C with respect to mole fraction and temperature, [m^6/mol^2/K]
- zs
- Returns
Notes
This equation can be derived with SymPy, as follows
>>> from sympy import * >>> from sympy import * >>> i, j, k, m, n, o, T = symbols("i, j, k, m, n, o, T", cls=Idx) >>> zs = IndexedBase('zs') >>> Cs = IndexedBase('Cs') >>> dC_dTs = IndexedBase('dC_dTs') >>> nc = symbols('nc') >>> C_expr = Sum(zs[i]*zs[j]*zs[k]/3*cbrt(Cs[i,j]*Cs[i,k]*Cs[j,k])/(Cs[i,j]*Cs[i,k]*Cs[j,k])*(Cs[i,j]*Cs[i,k]*dC_dTs[j,k] + Cs[i,j]*dC_dTs[i,k]*Cs[j,k] + dC_dTs[i,j]*Cs[i,k]*Cs[j,k]),[i,0,nc],[j,0,nc],[k,0,nc]) >>> diff(C_expr, zs[m]) Sum((Cs[i, j]*Cs[i, k]*Cs[j, k])**(1/3)*(Cs[i, j]*Cs[i, k]*dC_dTs[j, k] + Cs[i, j]*Cs[j, k]*dC_dTs[i, k] + Cs[i, k]*Cs[j, k]*dC_dTs[i, j])*KroneckerDelta(i, m)*zs[j]*zs[k]/(3*Cs[i, j]*Cs[i, k]*Cs[j, k]) + (Cs[i, j]*Cs[i, k]*Cs[j, k])**(1/3)*(Cs[i, j]*Cs[i, k]*dC_dTs[j, k] + Cs[i, j]*Cs[j, k]*dC_dTs[i, k] + Cs[i, k]*Cs[j, k]*dC_dTs[i, j])*KroneckerDelta(j, m)*zs[i]*zs[k]/(3*Cs[i, j]*Cs[i, k]*Cs[j, k]) + (Cs[i, j]*Cs[i, k]*Cs[j, k])**(1/3)*(Cs[i, j]*Cs[i, k]*dC_dTs[j, k] + Cs[i, j]*Cs[j, k]*dC_dTs[i, k] + Cs[i, k]*Cs[j, k]*dC_dTs[i, j])*KroneckerDelta(k, m)*zs[i]*zs[j]/(3*Cs[i, j]*Cs[i, k]*Cs[j, k]), (i, 0, nc), (j, 0, nc), (k, 0, nc))
Examples
>>> Cijs = [[1.46e-09, 1.831e-09, 2.12e-09], [1.831e-09, 2.46e-09, 2.996e-09], [2.12e-09, 2.996e-09, 4.927e-09]] >>> dCij_dTs = [[-2.212e-12, -4.137e-12, -1.079e-11], [-4.137e-12, -7.669e-12, -1.809e-11], [-1.079e-11, -1.809e-11, -2.010e-11]] >>> zs = [.5, .3, .2] >>> d2CVirial_mixture_Orentlicher_Prausnitz_dTdzs(zs, Cijs, dCij_dTs) [-1.5740994103e-11, -2.27267309501e-11, -3.56846953115e-11]
- chemicals.virial.dV_dzs_virial(B, C, V, dB_dzs, dC_dzs, dV_dzs=None)[source]¶
Calculates first mole fraction derivative of volume for the virial equation of state.
- Parameters
- B
float
Second virial coefficient in density form [m^3/mol]
- C
float
Third virial coefficient in density form [m^6/mol^2]
- V
float
Molar volume from virial equation, [m^3/mol]
- dB_dzs
list
[float
] First mole fraction derivatives of second virial coefficient in density form [m^3/mol]
- dC_dzs
list
[float
] First derivatives of C with respect to mole fraction, [m^6/mol^2]
- dV_dzs
list
[float
],optional
Array for first derivatives of molar volume with respect to mole fraction, [m^3/mol]
- B
- Returns
Notes
This expression was derived with SymPy as follows:
>>> from sympy import * >>> Z, R, T, P, z1 = symbols('Z, R, T, P, z1') >>> B, C, V = symbols('B, C, V', cls=Function) >>> base =Eq(P*V(z1)/(R*T), 1 + B(z1)/V(z1) + C(z1)/V(z1)**2) >>> P_sln = solve(base, P)[0] >>> solve(diff(P_sln, z1), Derivative(V(z1), z1)) [(V(z1)*Derivative(B(z1), z1) + Derivative(C(z1), z1))*V(z1)/(2*B(z1)*V(z1) + 3*C(z1) + V(z1)**2)]
Examples
>>> dV_dzs_virial(B=-5.130920247359858e-05, C=2.6627784284381213e-09, V=0.024892080086430797, dB_dzs=[-4.457911131778849e-05, -9.174964457681726e-05, -0.0001594258679841028], dC_dzs=[6.270599057032657e-09, 7.766612052069565e-09, 9.503031492910165e-09]) [-4.4510120473455416e-05, -9.181495962913208e-05, -0.00015970040988493522]
- chemicals.virial.d2V_dzizjs_virial(B, C, V, dB_dzs, dC_dzs, dV_dzs, d2B_dzizjs, d2C_dzizjs, d2V_dzizjs=None)[source]¶
Calculates second mole fraction derivative of volume for the virial equation of state.
- Parameters
- B
float
Second virial coefficient in density form [m^3/mol]
- C
float
Third virial coefficient in density form [m^6/mol^2]
- V
float
Molar volume from virial equation, [m^3/mol]
- dB_dzs
list
[float
] First mole fraction derivatives of second virial coefficient in density form [m^3/mol]
- dC_dzs
list
[float
] First derivatives of C with respect to mole fraction, [m^6/mol^2]
- dV_dzs
list
[float
] First derivatives of molar volume with respect to mole fraction, [m^3/mol]
- d2B_dzizjs
list
[list
[float
]] Second mole fraction derivatives of second virial coefficient in density form [m^3/mol]
- d2C_dzizjs
list
[list
[float
]] Second derivatives of C with respect to mole fraction, [m^6/mol^2]
- d2V_dzizjs
list
[list
[float
]],optional
Array for second derivatives of molar volume with respect to mole fraction, [m^3/mol]
- B
- Returns
Notes
This expression was derived with SymPy as follows:
>>> from sympy import * >>> Z, R, T, P, z1 = symbols('Z, R, T, P, z1') >>> B, C, V = symbols('B, C, V', cls=Function) >>> base =Eq(P*V(z1)/(R*T), 1 + B(z1)/V(z1) + C(z1)/V(z1)**2) >>> P_sln = solve(base, P)[0] >>> solve(diff(P_sln, z1), Derivative(V(z1), z1)) [(V(z1)*Derivative(B(z1), z1) + Derivative(C(z1), z1))*V(z1)/(2*B(z1)*V(z1) + 3*C(z1) + V(z1)**2)]
Examples
>>> d2C_dzizjs = [[1.0287075724127612e-08, 1.2388277824773021e-08, 1.4298813522844275e-08], [1.2388277824773021e-08, 1.514162073913238e-08, 1.8282527232061114e-08], [1.4298813522844275e-08, 1.8282527232061114e-08, 2.3350122217403063e-08]] >>> d2B_dzizjs = [[-1.0639357784985337e-05, -3.966321845899801e-05, -7.53987684376414e-05], [-3.966321845899801e-05, -8.286257232134107e-05, -0.00014128571574782375], [-7.53987684376414e-05, -0.00014128571574782375, -0.00024567752140887547]] >>> dB_dzs = [-4.457911131778849e-05, -9.174964457681726e-05, -0.0001594258679841028] >>> dC_dzs = [6.270599057032657e-09, 7.766612052069565e-09, 9.503031492910165e-09] >>> dV_dzs = [-4.4510120473455416e-05, -9.181495962913208e-05, -0.00015970040988493522] >>> d2V_dzizjs_virial(B=-5.130920247359858e-05, C=2.6627784284381213e-09, V=0.024892080086430797, dB_dzs=dB_dzs, dC_dzs=dC_dzs, dV_dzs=dV_dzs, d2B_dzizjs=d2B_dzizjs, d2C_dzizjs=d2C_dzizjs) [[-1.04268917389e-05, -3.9654694588e-05, -7.570310078e-05], [-3.9654694588e-05, -8.3270116767e-05, -0.0001423083584], [-7.5703100789e-05, -0.000142308358, -0.00024779788]]
Second Virial Correlations¶
- chemicals.virial.BVirial_Pitzer_Curl(T, Tc, Pc, omega, order=0)[source]¶
Calculates the second virial coefficient using the model in [1]. Designed for simple calculations.
- Parameters
- T
float
Temperature of fluid [K]
- Tc
float
Critical temperature of fluid [K]
- Pc
float
Critical pressure of the fluid [Pa]
- omega
float
Acentric factor for fluid, [-]
- order
int
,optional
Order of the calculation. 0 for the calculation of B itself; for 1/2/3, the first/second/third derivative of B with respect to temperature; and for -1/-2, the first/second indefinite integral of B with respect to temperature. No other integrals or derivatives are implemented, and an exception will be raised if any other order is given.
- T
- Returns
- B
float
Second virial coefficient in density form or its integral/derivative if specified, [m^3/mol or m^3/mol/K^order]
- B
Notes
Analytical models for derivatives and integrals are available for orders -2, -1, 1, 2, and 3, all obtained with SymPy.
For first temperature derivative of B:
For the second temperature derivative of B:
For the third temperature derivative of B:
For the first indefinite integral of B:
For the second indefinite integral of B:
References
- 1
Pitzer, Kenneth S., and R. F. Curl. “The Volumetric and Thermodynamic Properties of Fluids. III. Empirical Equation for the Second Virial Coefficient1.” Journal of the American Chemical Society 79, no. 10 (May 1, 1957): 2369-70. doi:10.1021/ja01567a007.
Examples
Example matching that in BVirial_Abbott, for isobutane.
>>> BVirial_Pitzer_Curl(510., 425.2, 38E5, 0.193) -0.00020845362479301725
- chemicals.virial.BVirial_Abbott(T, Tc, Pc, omega, order=0)[source]¶
Calculates the second virial coefficient using the model in [1]. Simple fit to the Lee-Kesler equation.
- Parameters
- T
float
Temperature of fluid [K]
- Tc
float
Critical temperature of fluid [K]
- Pc
float
Critical pressure of the fluid [Pa]
- omega
float
Acentric factor for fluid, [-]
- order
int
,optional
Order of the calculation. 0 for the calculation of B itself; for 1/2/3, the first/second/third derivative of B with respect to temperature; and for -1/-2, the first/second indefinite integral of B with respect to temperature. No other integrals or derivatives are implemented, and an exception will be raised if any other order is given.
- T
- Returns
- B
float
Second virial coefficient in density form or its integral/derivative if specified, [m^3/mol or m^3/mol/K^order]
- B
Notes
Analytical models for derivatives and integrals are available for orders -2, -1, 1, 2, and 3, all obtained with SymPy.
For first temperature derivative of B:
For the second temperature derivative of B:
For the third temperature derivative of B:
For the first indefinite integral of B:
For the second indefinite integral of B:
References
Examples
Example is from [1], p. 93, and matches the result exactly, for isobutane.
>>> BVirial_Abbott(510., 425.2, 38E5, 0.193) -0.000205701850095
- chemicals.virial.BVirial_Tsonopoulos(T, Tc, Pc, omega, order=0)[source]¶
Calculates the second virial coefficient using the model in [1].
- Parameters
- T
float
Temperature of fluid [K]
- Tc
float
Critical temperature of fluid [K]
- Pc
float
Critical pressure of the fluid [Pa]
- omega
float
Acentric factor for fluid, [-]
- order
int
,optional
Order of the calculation. 0 for the calculation of B itself; for 1/2/3, the first/second/third derivative of B with respect to temperature; and for -1/-2, the first/second indefinite integral of B with respect to temperature. No other integrals or derivatives are implemented, and an exception will be raised if any other order is given.
- T
- Returns
- B
float
Second virial coefficient in density form or its integral/derivative if specified, [m^3/mol or m^3/mol/K^order]
- B
Notes
A more complete expression is also available, in BVirial_Tsonopoulos_extended.
Analytical models for derivatives and integrals are available for orders -2, -1, 1, 2, and 3, all obtained with SymPy.
For first temperature derivative of B:
For the second temperature derivative of B:
For the third temperature derivative of B:
For the first indefinite integral of B:
For the second indefinite integral of B:
References
- 1
Tsonopoulos, Constantine. “An Empirical Correlation of Second Virial Coefficients.” AIChE Journal 20, no. 2 (March 1, 1974): 263-72. doi:10.1002/aic.690200209.
Examples
Example matching that in BVirial_Abbott, for isobutane.
>>> BVirial_Tsonopoulos(510., 425.2, 38E5, 0.193) -0.0002093529540
- chemicals.virial.BVirial_Tsonopoulos_extended(T, Tc, Pc, omega, a=0, b=0, species_type='', dipole=0, order=0)[source]¶
Calculates the second virial coefficient using the comprehensive model in [1]. See the notes for the calculation of a and b.
- Parameters
- T
float
Temperature of fluid [K]
- Tc
float
Critical temperature of fluid [K]
- Pc
float
Critical pressure of the fluid [Pa]
- omega
float
Acentric factor for fluid, [-]
- a
float
,optional
Fit parameter, calculated based on species_type if a is not given and species_type matches on of the supported chemical classes.
- b
float
,optional
Fit parameter, calculated based on species_type if a is not given and species_type matches on of the supported chemical classes.
- species_type
str
,optional
One of .
- dipole
float
dipole moment, optional, [Debye]
- order
int
,optional
Order of the calculation. 0 for the calculation of B itself; for 1/2/3, the first/second/third derivative of B with respect to temperature; and for -1/-2, the first/second indefinite integral of B with respect to temperature. No other integrals or derivatives are implemented, and an exception will be raised if any other order is given.
- T
- Returns
- B
float
Second virial coefficient in density form or its integral/derivative if specified, [m^3/mol or m^3/mol/K^order]
- B
Notes
Analytical models for derivatives and integrals are available for orders -2, -1, 1, 2, and 3, all obtained with SymPy.
To calculate a or b, the following rules are used:
For ‘simple’ or ‘normal’ fluids:
For ‘ketone’, ‘aldehyde’, ‘alkyl nitrile’, ‘ether’, ‘carboxylic acid’, or ‘ester’ types of chemicals:
For ‘alkyl halide’, ‘mercaptan’, ‘sulfide’, or ‘disulfide’ types of chemicals:
For ‘alkanol’ types of chemicals (except methanol):
For methanol:
For water:
If required, the form of dipole moment used in the calculation of some types of a and b values is as follows:
For first temperature derivative of B:
For the second temperature derivative of B:
For the third temperature derivative of B:
For the first indefinite integral of B:
For the second indefinite integral of B:
References
- 1
Tsonopoulos, C., and J. L. Heidman. “From the Virial to the Cubic Equation of State.” Fluid Phase Equilibria 57, no. 3 (1990): 261-76. doi:10.1016/0378-3812(90)85126-U
- 2
Tsonopoulos, Constantine, and John H. Dymond. “Second Virial Coefficients of Normal Alkanes, Linear 1-Alkanols (and Water), Alkyl Ethers, and Their Mixtures.” Fluid Phase Equilibria, International Workshop on Vapour-Liquid Equilibria and Related Properties in Binary and Ternary Mixtures of Ethers, Alkanes and Alkanols, 133, no. 1-2 (June 1997): 11-34. doi:10.1016/S0378-3812(97)00058-7.
Examples
Example from Perry’s Handbook, 8E, p2-499. Matches to a decimal place.
>>> BVirial_Tsonopoulos_extended(430., 405.65, 11.28E6, 0.252608, a=0, b=0, species_type='ketone', dipole=1.469) -9.679718337596e-05
New implementations, returning the derivatives as well
- chemicals.virial.BVirial_Pitzer_Curl_fast(T, Tc, Pc, omega)[source]¶
Implementation of
BVirial_Pitzer_Curl
in the interface which calculates virial coefficients and their derivatives at the same time.- Parameters
- Returns
- B
float
Second virial coefficient in density form [m^3/mol]
- dB_dT
float
First temperature derivative of second virial coefficient in density form [m^3/mol/K]
- d2B_dT2
float
Second temperature derivative of second virial coefficient in density form [m^3/mol/K^2]
- d3B_dT3
float
Third temperature derivative of second virial coefficient in density form [m^3/mol/K^3]
- B
Examples
>>> BVirial_Pitzer_Curl_fast(510., 425.2, 38E5, 0.193) (-0.000208453624, 1.065377516e-06, -5.7957101e-09, 4.513533043e-11)
- chemicals.virial.BVirial_Abbott_fast(T, Tc, Pc, omega)[source]¶
Implementation of
BVirial_Abbott
in the interface which calculates virial coefficients and their derivatives at the same time.- Parameters
- Returns
- B
float
Second virial coefficient in density form [m^3/mol]
- dB_dT
float
First temperature derivative of second virial coefficient in density form [m^3/mol/K]
- d2B_dT2
float
Second temperature derivative of second virial coefficient in density form [m^3/mol/K^2]
- d3B_dT3
float
Third temperature derivative of second virial coefficient in density form [m^3/mol/K^3]
- B
Examples
>>> BVirial_Abbott_fast(510., 425.2, 38E5, 0.193) (-0.0002057018500, 1.039249294e-06, -5.902233639e-09, 4.78222764e-11)
- chemicals.virial.BVirial_Tsonopoulos_fast(T, Tc, Pc, omega)[source]¶
Implementation of
BVirial_Tsonopoulos
in the interface which calculates virial coefficients and their derivatives at the same time.- Parameters
- Returns
- B
float
Second virial coefficient in density form [m^3/mol]
- dB_dT
float
First temperature derivative of second virial coefficient in density form [m^3/mol/K]
- d2B_dT2
float
Second temperature derivative of second virial coefficient in density form [m^3/mol/K^2]
- d3B_dT3
float
Third temperature derivative of second virial coefficient in density form [m^3/mol/K^3]
- B
Examples
>>> BVirial_Tsonopoulos_fast(510., 425.2, 38E5, 0.193) (-0.0002093529540, 9.95742355e-07, -5.54234465e-09, 4.57035160e-11)
- chemicals.virial.BVirial_Tsonopoulos_extended_fast(T, Tc, Pc, omega, a=0.0, b=0.0)[source]¶
Implementation of
BVirial_Tsonopoulos_extended
in the interface which calculates virial coefficients and their derivatives at the same time.- Parameters
- Returns
- B
float
Second virial coefficient in density form [m^3/mol]
- dB_dT
float
First temperature derivative of second virial coefficient in density form [m^3/mol/K]
- d2B_dT2
float
Second temperature derivative of second virial coefficient in density form [m^3/mol/K^2]
- d3B_dT3
float
Third temperature derivative of second virial coefficient in density form [m^3/mol/K^3]
- B
Examples
>>> BVirial_Tsonopoulos_extended_fast(510., 425.2, 38E5, 0.193) (-0.0002093529540, 9.9574235e-07, -5.54234465e-09, 4.5703516e-11)
- chemicals.virial.BVirial_Oconnell_Prausnitz(T, Tc, Pc, omega)[source]¶
Calculates the second virial coefficient using the model in [1].
- Parameters
- Returns
- B
float
Second virial coefficient in density form [m^3/mol]
- dB_dT
float
First temperature derivative of second virial coefficient in density form [m^3/mol/K]
- d2B_dT2
float
Second temperature derivative of second virial coefficient in density form [m^3/mol/K^2]
- d3B_dT3
float
Third temperature derivative of second virial coefficient in density form [m^3/mol/K^3]
- B
Notes
The coefficients are as follows:
c0 = 0.1445 c1 = -0.330 c2 = -0.1385 c3 = -0.0121
d0 = 0.073 d1 = 0.46 d2 = -0.50 d3 = -0.097 d4 = -0.0073
References
- 1
O`Connell, J. P., and J. M. Prausnitz. “Empirical Correlation of Second Virial Coefficients for Vapor-Liquid Equilibrium Calculations.” Industrial & Engineering Chemistry Process Design and Development 6, no. 2 (April 1, 1967): 245-50. https://doi.org/10.1021/i260022a016.
Examples
>>> BVirial_Oconnell_Prausnitz(510., 425.2, 38E5, 0.193) (-0.000203193781, 1.036185972e-06, -6.53679132e-09, 6.59478287e-11)
- chemicals.virial.BVirial_Xiang(T, Tc, Pc, Vc, omega)[source]¶
Calculates the second virial coefficient using the model in [1].
- Parameters
- Returns
- B
float
Second virial coefficient in density form [m^3/mol]
- dB_dT
float
First temperature derivative of second virial coefficient in density form [m^3/mol/K]
- d2B_dT2
float
Second temperature derivative of second virial coefficient in density form [m^3/mol/K^2]
- d3B_dT3
float
Third temperature derivative of second virial coefficient in density form [m^3/mol/K^3]
- B
References
- 1
Xiang, H. W. “The New Simple Extended Corresponding-States Principle: Vapor Pressure and Second Virial Coefficient.” Chemical Engineering Science 57, no. 8 (April 2002): 1439049. https://doi.org/10.1016/S0009-2509(02)00017-9.
Examples
>>> BVirial_Xiang(388.26, 647.1, 22050000.0, 5.543076e-05, 0.344) (-0.0004799570, 4.6778266e-06, -7.0157656e-08, 1.4137862e-09)
- chemicals.virial.BVirial_Meng(T, Tc, Pc, Vc, omega, a=0.0)[source]¶
Calculates the second virial coefficient using the model in [1].
- Parameters
- Returns
- B
float
Second virial coefficient in density form [m^3/mol]
- dB_dT
float
First temperature derivative of second virial coefficient in density form [m^3/mol/K]
- d2B_dT2
float
Second temperature derivative of second virial coefficient in density form [m^3/mol/K^2]
- d3B_dT3
float
Third temperature derivative of second virial coefficient in density form [m^3/mol/K^3]
- B
References
- 1
Meng, Long, Yuan-Yuan Duan, and Lei Li. “Correlations for Second and Third Virial Coefficients of Pure Fluids.” Fluid Phase Equilibria 226 (December 10, 2004): 109-20. https://doi.org/10.1016/j.fluid.2004.09.023.
Examples
>>> BVirial_Meng(388.26, 647.1, 22050000.0, 5.543076e-05, 0.344) (-0.00032436028, 2.47004e-06, -3.132e-08, 5.8e-10)
- chemicals.virial.Meng_virial_a(Tc, Pc, dipole=0.0, haloalkane=False)[source]¶
Calculate the a parameter which is used in the Meng B second virial coefficient for polar components. There are two correlations implemented - one for haloalkanes, and another for other polar molecules. If the dipole moment is not provided, a value of 0.0 will be returned.
If the compound is a haloalkane
Otherwise
- Parameters
- Returns
- a
float
Coefficient [-]
- a
References
- 1
Meng, Long, Yuan-Yuan Duan, and Lei Li. “Correlations for Second and Third Virial Coefficients of Pure Fluids.” Fluid Phase Equilibria 226 (December 10, 2004): 109-20. https://doi.org/10.1016/j.fluid.2004.09.023.
Examples
Ethanol
>>> Meng_virial_a(514.0, 6137000.0, 1.44, haloalkane=False) -0.00637841
R-41 Fluoromethane
>>> Meng_virial_a(317.4, 5870000.0, 1.85, haloalkane=True) -0.04493829
Third Virial Correlations¶
- chemicals.virial.CVirial_Orbey_Vera(T, Tc, Pc, omega)[source]¶
Calculates the third virial coefficient using the model in [1].
- Parameters
- Returns
- C
float
Third virial coefficient in density form [m^6/mol^2]
- dC_dT
float
First temperature derivative of third virial coefficient in density form [m^6/mol^2/K]
- d2C_dT2
float
Second temperature derivative of third virial coefficient in density form [m^6/mol^2/K^2]
- d3C_dT3
float
Third temperature derivative of third virial coefficient in density form [m^6/mol^2/K^3]
- C
References
- 1
Orbey, Hasan, and J. H. Vera. “Correlation for the Third Virial Coefficient Using Tc, Pc and ω as Parameters.” AIChE Journal 29, no. 1 (January 1, 1983): 107-13. https://doi.org/10.1002/aic.690290115.
Examples
n-octane
>>> CVirial_Orbey_Vera(T=300, Tc=568.7, Pc=2490000.0, omega=0.394) (-1.1107124e-05, 4.1326808e-07, -1.6041435e-08, 6.7035158e-10)