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.
Hansen Solubility Parameters¶
- chemicals.solubility.hansen_delta_d(CASRN, method=None)[source]¶
This function handles the retrieval of a chemical’s Hansen dispersive parameter (δD). Lookup is based on CASRNs. Will automatically select a data source to use if no method is provided; returns None if the data is not available.
- Parameters
- CASRN
str
CASRN [-]
- CASRN
- Returns
- delta_d
float
Hansen dispersive parameter, [Pa^0.5]
- delta_d
- Other Parameters
- method
str
,optional
A string for the method name to use, as defined in the variable, hansen_delta_d_all_methods.
- method
See also
Notes
The available sources are as follows:
References
- 1
Alshehri, Abdulelah S., Anjan K. Tula, Fengqi You, and Rafiqul Gani. “Next Generation Pure Component Property Estimation Models: With and without Machine Learning Techniques.” AIChE Journal 68, no. 6 (2022): e17469. https://doi.org/10.1002/aic.17469.
- 2
Ríos, Manuel Díaz de los, and Rubén Murcia Belmonte. “Extending Microsoft Excel and Hansen Solubility Parameters Relationship to Double Hansen’s Sphere Calculation.” SN Applied Sciences 4, no. 6 (May 24, 2022): 185. https://doi.org/10.1007/s42452-022-04959-4.
- 3
Joshua Schrier, “Hansen Solubility Parameters” from the Wolfram Data Repository (2020).
- 4
Alejandro Gutierrez, “HSPiPy”. GitHub Repository, https://github.com/Gnpd/HSPiPy.
Examples
>>> hansen_delta_d('64-17-5') 15800.0
- chemicals.solubility.hansen_delta_d_methods(CASRN)[source]¶
Return all methods available to obtain the Hansen solubility dispersive parameter (δD) for the desired chemical.
- Parameters
- CASRN
str
CASRN, [-]
- CASRN
- Returns
See also
- chemicals.solubility.hansen_delta_d_all_methods = ('MANUEL_RUBEN_2022', 'ALSHERI_HANSEN', 'HSPIPY', 'WDR_SCHRIER')¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- chemicals.solubility.hansen_delta_p(CASRN, method=None)[source]¶
This function handles the retrieval of a chemical’s Hansen polar parameter (δP). Lookup is based on CASRNs. Will automatically select a data source to use if no method is provided; returns None if the data is not available.
- Parameters
- CASRN
str
CASRN [-]
- CASRN
- Returns
- delta_p
float
Hansen polar parameter, [Pa^0.5]
- delta_p
- Other Parameters
- method
str
,optional
A string for the method name to use, as defined in the variable, hansen_delta_p_all_methods.
- method
See also
Notes
The available sources are as follows:
References
- 1
Alshehri, Abdulelah S., Anjan K. Tula, Fengqi You, and Rafiqul Gani. “Next Generation Pure Component Property Estimation Models: With and without Machine Learning Techniques.” AIChE Journal 68, no. 6 (2022): e17469. https://doi.org/10.1002/aic.17469.
- 2
Ríos, Manuel Díaz de los, and Rubén Murcia Belmonte. “Extending Microsoft Excel and Hansen Solubility Parameters Relationship to Double Hansen’s Sphere Calculation.” SN Applied Sciences 4, no. 6 (May 24, 2022): 185. https://doi.org/10.1007/s42452-022-04959-4.
- 3
Joshua Schrier, “Hansen Solubility Parameters” from the Wolfram Data Repository (2020).
- 4
Alejandro Gutierrez, “HSPiPy”. GitHub Repository, https://github.com/Gnpd/HSPiPy.
Examples
>>> hansen_delta_p('64-17-5') 8800.0
- chemicals.solubility.hansen_delta_p_methods(CASRN)[source]¶
Return all methods available to obtain the Hansen solubility polar parameter (δP) for the desired chemical.
- Parameters
- CASRN
str
CASRN, [-]
- CASRN
- Returns
See also
- chemicals.solubility.hansen_delta_p_all_methods = ('MANUEL_RUBEN_2022', 'ALSHERI_HANSEN', 'HSPIPY', 'WDR_SCHRIER')¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- chemicals.solubility.hansen_delta_h(CASRN, method=None)[source]¶
This function handles the retrieval of a chemical’s Hansen hydrogen bonding parameter (δH). Lookup is based on CASRNs. Will automatically select a data source to use if no method is provided; returns None if the data is not available.
- Parameters
- CASRN
str
CASRN [-]
- CASRN
- Returns
- delta_h
float
Hansen hydrogen bonding parameter, [Pa^0.5]
- delta_h
- Other Parameters
- method
str
,optional
A string for the method name to use, as defined in the variable, hansen_delta_h_all_methods.
- method
See also
Notes
The available sources are as follows:
References
- 1
Alshehri, Abdulelah S., Anjan K. Tula, Fengqi You, and Rafiqul Gani. “Next Generation Pure Component Property Estimation Models: With and without Machine Learning Techniques.” AIChE Journal 68, no. 6 (2022): e17469. https://doi.org/10.1002/aic.17469.
- 2
Ríos, Manuel Díaz de los, and Rubén Murcia Belmonte. “Extending Microsoft Excel and Hansen Solubility Parameters Relationship to Double Hansen’s Sphere Calculation.” SN Applied Sciences 4, no. 6 (May 24, 2022): 185. https://doi.org/10.1007/s42452-022-04959-4.
- 3
Joshua Schrier, “Hansen Solubility Parameters” from the Wolfram Data Repository (2020).
- 4
Alejandro Gutierrez, “HSPiPy”. GitHub Repository, https://github.com/Gnpd/HSPiPy.
Examples
>>> hansen_delta_h('64-17-5') 19400.0
- chemicals.solubility.hansen_delta_h_methods(CASRN)[source]¶
Return all methods available to obtain the Hansen solubility hydrogen bonding parameter (δH) for the desired chemical.
- Parameters
- CASRN
str
CASRN, [-]
- CASRN
- Returns
See also
- chemicals.solubility.hansen_delta_h_all_methods = ('MANUEL_RUBEN_2022', 'ALSHERI_HANSEN', 'HSPIPY', 'WDR_SCHRIER')¶
Tuple of method name keys. See the hansen_delta_d for the actual references
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.
- Parameters
- T
float
Temperature, [K]
- A
float
Constant term on exponential, [-]
- B
float
,optional
Inverse temperature term on exponential, [K]
- C
float
,optional
Logarithmic term on exponential, [-]
- D
float
,optional
Linear term on exponential, [1/K]
- E
float
,optional
Inverse quadratic temperature term on exponential, [K]
- F
float
,optional
Quadratic temperature term on exponential, [1/K^2]
- T
- Returns
- H12
float
Henry’s constant [Pa]
- H12
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
- Returns
- H
value
Henry’s law constant for the gas in the liquid phase, [-]
- H
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
- val
float
Henry’s law constant, various units
- old_scale
str
String representing the scale that val is in originally.
- new_scale
str
String representing the scale that val should be converted to.
- rhom
float
,optional
The molar density of the fluid [mol/m^3]
- MW
float
,optional
The molecular weight of the fluid [g/mol]
- val
- Returns
- result
float
Input val converted from old_scale to new_scale, various units
- result
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:
- Parameters
- lnHenry_matrix
list
[list
[float
]] Henry’s law constants between every species; 0.0 for non-applicable solvents, [log(Pa)]
- zs
list
[float
] Mole fractions of all species in phase; this can be mass or volume fractions as well, [-]
- henry_components
list
[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, [-]
- Hs
list
[float
],optional
Henry’s law constants for each component; 0 for non-henry components (input array), [Pa]
- lnHenry_matrix
- Returns
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_matrix
list
[list
[float
]] Henry’s law constants between every species; 0.0 for non-applicable solvents, [log(Pa)]
- dlnHenry_matrix_dT
list
[list
[float
]] First temperature derivative of Henry’s law constants between every species; 0.0 for non-applicable solvents, [log(Pa)/K]
- zs
list
[float
] Mole fractions of all species in phase; this can be mass or volume fractions as well, [-]
- henry_components
list
[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_dTs
list
[float
],optional
First temperature derivative of Henry’s law constants for each component; 0 for non-henry components (input array), [Pa/K]
- lnHenry_matrix
- Returns
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_matrix
list
[list
[float
]] Henry’s law constants between every species; 0.0 for non-applicable solvents, [log(Pa)]
- dlnHenry_matrix_dT
list
[list
[float
]] First temperature derivative of Henry’s law constants between every species; 0.0 for non-applicable solvents, [log(Pa)/K]
- d2lnHenry_matrix_dT2
list
[list
[float
]] Second temperature derivative of Henry’s law constants between every species; 0.0 for non-applicable solvents, [log(Pa)/K^2]
- zs
list
[float
] Mole fractions of all species in phase; this can be mass or volume fractions as well, [-]
- henry_components
list
[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_dT2s
list
[float
],optional
Second temperature derivative of Henry’s law constants for each component; 0 for non-henry components (input array), [Pa/K^2]
- lnHenry_matrix
- Returns
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.
- Parameters
- T
float
Temperature of the system [K]
- Tm
float
Melting temperature of the solute [K]
- Hm
float
Heat of melting at the melting temperature of the solute [J/mol]
- Cpl
float
,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]
- gamma
float
,optional
Activity coefficient of the solute as a liquid [-]
- T
- Returns
- x
float
Mole fraction of solute at maximum solubility [-]
- x
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.
- Parameters
- Returns
- delta
float
Solubility parameter, [Pa^0.5]
- delta
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.
- Parameters
- Returns
- dTm
float
Freezing point depression [K]
- dTm
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