Solubility (chemicals.solubility)

This module contains various solubility calculation routines and a Henry’s law coefficient converter.

For reporting bugs, adding feature requests, or submitting pull requests, please use the GitHub issue tracker.

Henry’s Law

chemicals.solubility.Henry_pressure(T, A, B=0.0, C=0.0, D=0.0, E=0.0, F=0.0)[source]

Calculates Henry’s law constant as a function of temperature according to the SI units of Pa and using a common temperature dependence as used in many process simulation applications.

Only the A parameter is required - which has no temperature dependence when used by itself. As the model is exponential, a sufficiently high temperature may cause an OverflowError. A negative temperature (or just low, if fit poorly) may cause a math domain error.

H12=exp(A12+B12T+C12ln(T)+D12T+E12T2)H_{12} = \exp\left(A_{12} + \frac{B_{12}}{T} + C_{12}\ln(T) + D_{12}T + \frac{E_{12}}{T^2} \right)
Parameters
Tfloat

Temperature, [K]

A-Ffloat

Parameter for the equation; chemical and property specific [-]

Returns
H12float

Henry’s constant [Pa]

Notes

Add 11.51292 to the A constant if it is said to provide units of bar, so that it provides units of Pa instead.

The F parameter is not often included in models. It is rare to fit all parameters.

References

1

Gmehling, Jurgen. Chemical Thermodynamics: For Process Simulation. Weinheim, Germany: Wiley-VCH, 2012.

Examples

Random test example.

>>> Henry_pressure(300.0, A=15.0, B=300.0, C=.04, D=1e-3, E=1e2, F=1e-5)
37105004.47898146
chemicals.solubility.Henry_pressure_mixture(Hs, weights=None, zs=None)[source]

Mixing rule for Henry’s law components. Applies a logarithmic average to all solvent components and mole fractions. Optionally, weight factors can be provided instead of using mole fractions - only specify one of them.

A common weight factor is using volume fractions of powers of them, or using critical volumes.

Parameters
Hslist[float or None]

Henry’s law constant between each gas and the solvent (None for other solvents of gases without parameters available), [Pa]

weightslist[float], optional

Weight factors, [-]

zslist[float]

Mole fractions of all species in phase, [-]

Returns
Hvalue

Henry’s law constant for the gas in the liquid phase, [-]

Notes

The default weight factor formulation is from [1].

References

1

Gmehling, Jurgen. Chemical Thermodynamics: For Process Simulation. Weinheim, Germany: Wiley-VCH, 2012.

Examples

>>> Henry_pressure_mixture([1072330.36341, 744479.751106, None], zs=[.48, .48, .04])
893492.1611602883
chemicals.solubility.Henry_converter(val, old_scale, new_scale, rhom=None, MW=None)[source]

Converts Henry’s law constant for a gas with respect to a solvent from one scale to another.

There are many scales, but it is recommemed to operate in the scale of SI - which returns a value with units Pa, and directly gets used in place of vapor pressure inside a flash calculation. This removes the complexity of Henry’s law, avoiding possible simplication in favor of use with other thermodynamic models.

Only some scales require the molecular weight and the molar density of the solvent. Values for water, the most common solute, are 55344.59 mol/m^3 at STP and 18.01528 g/mol.

Parameters
valfloat

Henry’s law constant, various units

old_scalestr

String representing the scale that val is in originally.

new_scalestr

String representing the scale that val should be converted to.

Returns
resultfloat

Input val converted from old_scale to new_scale, various units

Notes

The valid scales for this function are any of the following:

(‘Hcp’, ‘mol/(m^3*Pa)’, ‘M/atm’, ‘Hcc’, ‘mol/(kg*Pa)’, ‘Hbp’, ‘mol/(kg*atm)’, ‘Hxp’, ‘1/atm’, ‘alpha’, ‘bunsen coefficient’, ‘KHpx’, ‘atm’, ‘m^3*Pa/mol’, ‘KHpc’, ‘m^3*atm/mol’, ‘KHcc’, ‘SI’)

References

1

Green, Don, and Robert Perry. Perry’s Chemical Engineers’ Handbook, 8E. McGraw-Hill Professional, 2007.

Examples

>>> Henry_converter(1.2e-5, old_scale='Hcp', new_scale='SI', rhom=55344.59,
... MW=18.01528)
4612049166.666666
>>> Henry_converter(0.0297475, old_scale='Hcc', new_scale='KHcc',
... rhom=55344.59, MW=18.01528)
33.61627027481301
chemicals.solubility.Henry_constants(lnHenry_matrix, zs, henry_components, skip_zero=True, Hs=None)[source]

Calculate the Henry’s law constants for a list of components, only some of which are henry’s law following components (solutes) and the rest that are solvents. The empirical mixing rule from [1] is used as follows:

Hi=exp(j=solventzjlnHi,jj=solventzj)H_i = \exp\left(\frac{\sum_{\text{j=solvent}} z_j \ln H_{i,j}} {\sum_{\text{j=solvent}} z_j}\right)
Parameters
lnHenry_matrixlist[list[float]]

Henry’s law constants between every species; 0.0 for non-applicable solvents, [log(Pa)]

zslist[float]

Mole fractions of all species in phase; this can be mass or volume fractions as well, [-]

henry_componentslist[bool]

Whether or not each component is a henry’s law solvent or not, [-]

skip_zerobool

If true, if parameters are missing from a solvent-solute pair, that pair will not be counted as part of the solvent fraction. If false, the calculation proceeds and the solubility is underestimated. Missing parameters are assumed from the value of lnHenry_matrix being 0, [-]

Hslist[float], optional

Henry’s law constants for each component; 0 for non-henry components (input array), [Pa]

Returns
Hslist[float]

Henry’s law constants for each component; 0 for non-henry components, [Pa]

References

1

Gmehling, Jurgen. Chemical Thermodynamics: For Process Simulation. Weinheim, Germany: Wiley-VCH, 2012.

Examples

Oxygen and methane in water:

>>> lnHenry_matrix = [[0.0, 0.0, 0.0], [22.13581843104147, 0.0, 0.0], [22.239038459475733, 0.0, 0.0]]
>>> Henry_constants(lnHenry_matrix, [0.8, 0.15, 0.05], [False, True, True], True)
[0.0, 4106424071.093, 4552937470.331]
chemicals.solubility.dHenry_constants_dT(lnHenry_matrix, dlnHenry_matrix_dT, zs, henry_components, skip_zero=True, dH_dTs=None)[source]

Calculate the first temperature derivative of Henry’s law constants for a list of components, only some of which are henry’s law following components (solutes) and the rest that are solvents. The empirical mixing rule from [1] is used as follows:

Parameters
lnHenry_matrixlist[list[float]]

Henry’s law constants between every species; 0.0 for non-applicable solvents, [log(Pa)]

dlnHenry_matrix_dTlist[list[float]]

First temperature derivative of Henry’s law constants between every species; 0.0 for non-applicable solvents, [log(Pa)/K]

zslist[float]

Mole fractions of all species in phase; this can be mass or volume fractions as well, [-]

henry_componentslist[bool]

Whether or not each component is a henry’s law solvent or not, [-]

skip_zerobool

If true, if parameters are missing from a solvent-solute pair, that pair will not be counted as part of the solvent fraction. If false, the calculation proceeds and the solubility is underestimated. Missing parameters are assumed from the value of lnHenry_matrix being 0, [-]

dH_dTslist[float], optional

First temperature derivative of Henry’s law constants for each component; 0 for non-henry components (input array), [Pa/K]

Returns
dH_dTslist[float]

First temperature derivative of Henry’s law constants for each component; 0 for non-henry components, [Pa/K]

References

1

Gmehling, Jurgen. Chemical Thermodynamics: For Process Simulation. Weinheim, Germany: Wiley-VCH, 2012.

Examples

Oxygen and methane in water:

>>> lnHenry_matrix = [[0.0, 0.0, 0.0], [22.13581843104147, 0.0, 0.0], [22.239038459475733, 0.0, 0.0]]
>>> dlnHenry_matrix_dT = [[0.0, 0.0, 0.0], [0.017113988888888904, 0.0, 0.0], [0.015461911111111101, 0.0, 0.0]]
>>> dHenry_constants_dT(lnHenry_matrix, dlnHenry_matrix_dT, [0.8, 0.15, 0.05], [False, True, True], True)
[0.0, 70277295.92576516, 70397114.46071726]
chemicals.solubility.d2Henry_constants_dT2(lnHenry_matrix, dlnHenry_matrix_dT, d2lnHenry_matrix_dT2, zs, henry_components, skip_zero=True, d2H_dT2s=None)[source]

Calculate the second temperature derivative of Henry’s law constants for a list of components, only some of which are henry’s law following components (solutes) and the rest that are solvents. The empirical mixing rule from [1] is used as follows:

Parameters
lnHenry_matrixlist[list[float]]

Henry’s law constants between every species; 0.0 for non-applicable solvents, [log(Pa)]

dlnHenry_matrix_dTlist[list[float]]

First temperature derivative of Henry’s law constants between every species; 0.0 for non-applicable solvents, [log(Pa)/K]

d2lnHenry_matrix_dT2list[list[float]]

Second temperature derivative of Henry’s law constants between every species; 0.0 for non-applicable solvents, [log(Pa)/K^2]

zslist[float]

Mole fractions of all species in phase; this can be mass or volume fractions as well, [-]

henry_componentslist[bool]

Whether or not each component is a henry’s law solvent or not, [-]

skip_zerobool

If true, if parameters are missing from a solvent-solute pair, that pair will not be counted as part of the solvent fraction. If false, the calculation proceeds and the solubility is underestimated. Missing parameters are assumed from the value of lnHenry_matrix being 0, [-]

d2H_dT2slist[float], optional

Second temperature derivative of Henry’s law constants for each component; 0 for non-henry components (input array), [Pa/K^2]

Returns
d2H_dT2slist[float]

Second temperature derivative of Henry’s law constants for each component; 0 for non-henry components, [Pa/K^2]

References

1

Gmehling, Jurgen. Chemical Thermodynamics: For Process Simulation. Weinheim, Germany: Wiley-VCH, 2012.

Examples

Oxygen and methane in water:

>>> lnHenry_matrix = [[0.0, 0.0, 0.0], [22.13581843104147, 0.0, 0.0], [22.239038459475733, 0.0, 0.0]]
>>> dlnHenry_matrix_dT = [[0.0, 0.0, 0.0], [0.017113988888888904, 0.0, 0.0], [0.015461911111111101, 0.0, 0.0]]
>>> d2lnHenry_matrix_dT2 = [[0.0, 0.0, 0.0], [-0.0004070325925925928, 0.0, 0.0], [-0.00034016518518518524, 0.0, 0.0]]
>>> d2Henry_constants_dT2(lnHenry_matrix, dlnHenry_matrix_dT, d2lnHenry_matrix_dT2, [0.8, 0.15, 0.05], [False, True, True], True)
[0.0, -468723.574327235, -460276.89146166]

Utility functions

chemicals.solubility.solubility_eutectic(T, Tm, Hm, Cpl=0, Cps=0, gamma=1)[source]

Returns the maximum solubility of a solute in a solvent.

lnxiLγiL=ΔHm,iRT(1TTm,i)ΔCp,i(Tm,iT)RT+ΔCp,iRlnTmT\ln x_i^L \gamma_i^L = \frac{\Delta H_{m,i}}{RT}\left( 1 - \frac{T}{T_{m,i}}\right) - \frac{\Delta C_{p,i}(T_{m,i}-T)}{RT} + \frac{\Delta C_{p,i}}{R}\ln\frac{T_m}{T}
ΔCp,i=Cp,iLCp,iS\Delta C_{p,i} = C_{p,i}^L - C_{p,i}^S
Parameters
Tfloat

Temperature of the system [K]

Tmfloat

Melting temperature of the solute [K]

Hmfloat

Heat of melting at the melting temperature of the solute [J/mol]

Cplfloat, optional

Molar heat capacity of the solute as a liquid [J/mol/K]

Cps: float, optional

Molar heat capacity of the solute as a solid [J/mol/K]

gammafloat, optional

Activity coefficient of the solute as a liquid [-]

Returns
xfloat

Mole fraction of solute at maximum solubility [-]

Notes

gamma is of the solute in liquid phase

References

1

Gmehling, Jurgen. Chemical Thermodynamics: For Process Simulation. Weinheim, Germany: Wiley-VCH, 2012.

Examples

From [1], matching example

>>> solubility_eutectic(T=260., Tm=278.68, Hm=9952., Cpl=0, Cps=0, gamma=3.0176)
0.243400713
chemicals.solubility.solubility_parameter(T, Hvapm, Vml)[source]

This function handles the calculation of a chemical’s solubility parameter. Calculation is a function of temperature, but is not always presented as such. Hvapm, Vml, T are required.

δ=ΔHvapRTVm\delta = \sqrt{\frac{\Delta H_{vap} - RT}{V_m}}
Parameters
Tfloat

Temperature of the fluid [k]

Hvapmfloat

Heat of vaporization [J/mol/K]

Vmlfloat

Specific volume of the liquid [m^3/mol]

Returns
deltafloat

Solubility parameter, [Pa^0.5]

Notes

Undefined past the critical point. For convenience, if Hvap is not defined, an error is not raised; None is returned instead. Also for convenience, if Hvapm is less than RT, None is returned to avoid taking the root of a negative number.

This parameter is often given in units of cal/ml, which is 2045.48 times smaller than the value returned here.

References

1

Barton, Allan F. M. CRC Handbook of Solubility Parameters and Other Cohesion Parameters, Second Edition. CRC Press, 1991.

Examples

Pentane at STP

>>> solubility_parameter(T=298.2, Hvapm=26403.3, Vml=0.000116055)
14357.68128600315
chemicals.solubility.Tm_depression_eutectic(Tm, Hm, x=None, M=None, MW=None)[source]

Returns the freezing point depression caused by a solute in a solvent. Can use either the mole fraction of the solute or its molality and the molecular weight of the solvent. Assumes ideal system behavior.

ΔTm=RTm2xΔHm\Delta T_m = \frac{R T_m^2 x}{\Delta H_m}
ΔTm=RTm2(MW)M1000ΔHm\Delta T_m = \frac{R T_m^2 (MW) M}{1000 \Delta H_m}
Parameters
Tmfloat

Melting temperature of the solute [K]

Hmfloat

Heat of melting at the melting temperature of the solute [J/mol]

xfloat, optional

Mole fraction of the solute [-]

Mfloat, optional

Molality [mol/kg]

MW: float, optional

Molecular weight of the solvent [g/mol]

Returns
dTmfloat

Freezing point depression [K]

Notes

MW is the molecular weight of the solvent. M is the molality of the solute.

References

1

Gmehling, Jurgen. Chemical Thermodynamics: For Process Simulation. Weinheim, Germany: Wiley-VCH, 2012.

Examples

From [1], matching example.

>>> Tm_depression_eutectic(353.35, 19110, .02)
1.0864598583150