pyEQL 0.5.2__py3-none-any.whl → 1.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. pyEQL/__init__.py +50 -43
  2. pyEQL/activity_correction.py +481 -707
  3. pyEQL/database/geothermal.dat +5693 -0
  4. pyEQL/database/llnl.dat +19305 -0
  5. pyEQL/database/phreeqc_license.txt +54 -0
  6. pyEQL/database/pyeql_db.json +35902 -0
  7. pyEQL/engines.py +793 -0
  8. pyEQL/equilibrium.py +148 -228
  9. pyEQL/functions.py +121 -416
  10. pyEQL/pint_custom_units.txt +2 -2
  11. pyEQL/presets/Ringers lactate.yaml +20 -0
  12. pyEQL/presets/normal saline.yaml +17 -0
  13. pyEQL/presets/rainwater.yaml +17 -0
  14. pyEQL/presets/seawater.yaml +29 -0
  15. pyEQL/presets/urine.yaml +26 -0
  16. pyEQL/presets/wastewater.yaml +21 -0
  17. pyEQL/salt_ion_match.py +53 -284
  18. pyEQL/solute.py +126 -191
  19. pyEQL/solution.py +2163 -2090
  20. pyEQL/utils.py +165 -0
  21. pyEQL-1.1.0.dist-info/AUTHORS.md +13 -0
  22. {pyEQL-0.5.2.dist-info → pyEQL-1.1.0.dist-info}/COPYING +1 -1
  23. pyEQL-0.5.2.dist-info/LICENSE → pyEQL-1.1.0.dist-info/LICENSE.txt +3 -7
  24. pyEQL-1.1.0.dist-info/METADATA +129 -0
  25. pyEQL-1.1.0.dist-info/RECORD +27 -0
  26. {pyEQL-0.5.2.dist-info → pyEQL-1.1.0.dist-info}/WHEEL +2 -1
  27. pyEQL/chemical_formula.py +0 -1006
  28. pyEQL/database/Erying_viscosity.tsv +0 -18
  29. pyEQL/database/Jones_Dole_B.tsv +0 -32
  30. pyEQL/database/Jones_Dole_B_inorganic_Jenkins.tsv +0 -75
  31. pyEQL/database/LICENSE +0 -4
  32. pyEQL/database/dielectric_parameter.tsv +0 -30
  33. pyEQL/database/diffusion_coefficient.tsv +0 -116
  34. pyEQL/database/hydrated_radius.tsv +0 -35
  35. pyEQL/database/ionic_radius.tsv +0 -35
  36. pyEQL/database/partial_molar_volume.tsv +0 -22
  37. pyEQL/database/pitzer_activity.tsv +0 -169
  38. pyEQL/database/pitzer_volume.tsv +0 -132
  39. pyEQL/database/template.tsv +0 -14
  40. pyEQL/database.py +0 -300
  41. pyEQL/elements.py +0 -4552
  42. pyEQL/logging_system.py +0 -53
  43. pyEQL/parameter.py +0 -435
  44. pyEQL/tests/__init__.py +0 -32
  45. pyEQL/tests/test_activity.py +0 -578
  46. pyEQL/tests/test_bulk_properties.py +0 -86
  47. pyEQL/tests/test_chemical_formula.py +0 -279
  48. pyEQL/tests/test_debye_length.py +0 -79
  49. pyEQL/tests/test_density.py +0 -106
  50. pyEQL/tests/test_dielectric.py +0 -153
  51. pyEQL/tests/test_effective_pitzer.py +0 -276
  52. pyEQL/tests/test_mixed_electrolyte_activity.py +0 -154
  53. pyEQL/tests/test_osmotic_coeff.py +0 -99
  54. pyEQL/tests/test_pyeql_volume_concentration.py +0 -428
  55. pyEQL/tests/test_salt_matching.py +0 -337
  56. pyEQL/tests/test_solute_properties.py +0 -251
  57. pyEQL/water_properties.py +0 -352
  58. pyEQL-0.5.2.dist-info/AUTHORS +0 -7
  59. pyEQL-0.5.2.dist-info/METADATA +0 -72
  60. pyEQL-0.5.2.dist-info/RECORD +0 -47
  61. pyEQL-0.5.2.dist-info/entry_points.txt +0 -3
  62. {pyEQL-0.5.2.dist-info → pyEQL-1.1.0.dist-info}/top_level.txt +0 -0
@@ -1,5 +1,5 @@
1
1
  """
2
- pyEQL activity correction library
2
+ pyEQL activity correction library.
3
3
 
4
4
  This file contains functions for computing molal-scale activity coefficients
5
5
  of ions and salts in aqueous solution.
@@ -8,402 +8,313 @@ Individual functions for activity coefficients are defined here so that they
8
8
  can be used independently of a pyEQL solution object. Normally, these functions
9
9
  are called from within the get_activity_coefficient method of the Solution class.
10
10
 
11
- :copyright: 2013-2020 by Ryan S. Kingsbury
11
+ :copyright: 2013-2024 by Ryan S. Kingsbury
12
12
  :license: LGPL, see LICENSE for more details.
13
13
 
14
14
  """
15
- import math
16
15
 
17
- # functions for properties of water
18
- import pyEQL.water_properties as h2o
19
-
20
- # the pint unit registry
21
- from pyEQL import unit
22
-
23
- # add a filter to emit only unique log messages to the handler
24
- from pyEQL.logging_system import Unique
25
-
26
- # logging system
27
16
  import logging
28
17
 
29
- logger = logging.getLogger(__name__)
18
+ import numpy as np
19
+ from pint import Quantity
30
20
 
31
- unique = Unique()
32
- logger.addFilter(unique)
21
+ from pyEQL import ureg
22
+ from pyEQL.utils import create_water_substance
33
23
 
34
- # add a handler for console output, since pyEQL is meant to be used interactively
35
- ch = logging.StreamHandler()
24
+ logger = logging.getLogger(f"pyEQL.{__name__}")
36
25
 
37
- # create formatter for the log
38
- formatter = logging.Formatter("(%(name)s) - %(levelname)s - %(message)s")
39
26
 
40
- # add formatter to the handler
41
- ch.setFormatter(formatter)
42
- logger.addHandler(ch)
27
+ def _debye_parameter_B(temperature: str = "25 degC") -> Quantity:
28
+ r"""
29
+ Return the constant B used in the extended Debye-Huckel equation.
43
30
 
31
+ Args:
32
+ temperature: The temperature of the solution at which to calculate the constant.
33
+ Defaults to '25 degC'.
44
34
 
45
- def _debye_parameter_B(temperature="25 degC"):
46
- """
47
- Return the constant B used in the extended Debye-Huckel equation
35
+ Returns:
36
+ The parameter B for use in extended Debye-Huckel equation (base e). For base 10,
37
+ divide the resulting value by 2.303. Note that A is often given in base 10 terms
38
+ in older textbooks and reference material (0.3281 at 25 degC).
39
+
40
+ Notes:
41
+ The parameter B is equal to:
48
42
 
49
- Parameters
50
- ----------
51
- temperature : str Quantity, optional
52
- String representing the temperature of the solution. Defaults to '25 degC' if not specified.
43
+ .. math::
53
44
 
54
- Notes
55
- -----
56
- The parameter B is equal to: [#]_
45
+ B = \bigg( \frac{2 N_A \rho_w e^2}{\epsilon_o \epsilon_r k T} \bigg) ^ {\frac{1}{2}}
57
46
 
58
- .. math:: B = ( {8 \\pi N_A e^2 \\over 1000 \\epsilon k T} ) ^ {1 \\over 2}
47
+ References:
48
+ Bockris and Reddy. /Modern Electrochemistry/, vol 1. Plenum/Rosetta, 1977, p.210.
59
49
 
60
- .. [#] Bockris and Reddy. /Modern Electrochemistry/, vol 1. Plenum/Rosetta, 1977, p.210.
50
+ Archer, Donald G. and Wang, Peiming. "The Dielectric Constant of Water \
51
+ and Debye-Huckel Limiting Law Slopes." /J. Phys. Chem. Ref. Data/ 19(2), 1990.
61
52
 
62
- Examples
63
- --------
64
- >>> _debye_parameter_B() #doctest: +ELLIPSIS
65
- 0.3291...
53
+ https://chem.libretexts.org/Bookshelves/Physical_and_Theoretical_Chemistry_Textbook_Maps/Physical_Chemistry_(LibreTexts)/25%3A_Solutions_II_-_Nonvolatile_Solutes/25.06%3A_The_Debye-Huckel_Theory
66
54
 
55
+ https://en.wikipedia.org/wiki/Debye%E2%80%93H%C3%BCckel_equation
67
56
  """
68
- # TODO - fix this and resolve units
57
+ T = ureg.Quantity(temperature)
58
+ water_substance = create_water_substance(
59
+ T,
60
+ ureg.Quantity(1, "atm"),
61
+ )
62
+
69
63
  param_B = (
70
- 8
71
- * math.pi
72
- * unit.avogadro_constant
73
- * unit.elementary_charge ** 2
74
- / (
75
- h2o.water_density(unit(temperature))
76
- * unit.epsilon_0
77
- * h2o.water_dielectric_constant(unit(temperature))
78
- * unit.boltzmann_constant
79
- * unit(temperature)
80
- )
64
+ 2
65
+ * ureg.N_A
66
+ * ureg.Quantity(water_substance.rho, "g/L")
67
+ * ureg.elementary_charge**2
68
+ / (ureg.epsilon_0 * water_substance.epsilon * ureg.boltzmann_constant * T)
81
69
  ) ** 0.5
82
70
  return param_B.to_base_units()
83
71
 
84
72
 
85
- def _debye_parameter_activity(temperature="25 degC"):
86
- """
87
- Return the constant A for use in the Debye-Huckel limiting law (base 10)
73
+ def _debye_parameter_activity(temperature: str = "25 degC") -> "Quantity":
74
+ r"""
75
+ Return the constant A for use in the Debye-Huckel limiting law (base e).
76
+
77
+ Args:
78
+ temperature: The temperature of the solution at which to calculate the constant.
79
+ Defaults to '25 degC'.
88
80
 
89
- Parameters
90
- ----------
91
- temperature : str Quantity, optional
92
- String representing the temperature of the solution. Defaults to '25 degC' if not specified.
81
+ Returns:
82
+ The parameter A for use in the Debye-Huckel limiting law (base e). For base 10,
83
+ divide the resulting value by 2.303. Note that A is often given in base 10 terms
84
+ in older textbooks and reference material (0.509 at 25 degC).
93
85
 
94
- Returns
95
- -------
96
- Quantity The parameter A for use in the Debye-Huckel limiting law (base e)
86
+ Notes:
87
+ The parameter A is equal to:
97
88
 
98
- Notes
99
- -----
89
+ .. math::
100
90
 
101
- The parameter A is equal to: [#]_
91
+ A^{\gamma} = \frac{e^3 \big( 2 \pi N_A \rho \big)^{0.5}}{(4 \pi \epsilon_o \epsilon_r k T)^{1.5}}
102
92
 
103
- .. math::
104
- A^{\\gamma} = {e^3 ( 2 \\pi N_A {\\rho})^{0.5} \\over (4 \\pi \\epsilon_o \\epsilon_r k T)^{1.5}}
93
+ Note that this equation returns the parameter value that can be used to calculate
94
+ the natural logarithm of the activity coefficient. For base 10, divide the
95
+ value returned by 2.303.
105
96
 
106
- Note that this equation returns the parameter value that can be used to calculate
107
- the natural logarithm of the activity coefficient. For base 10, divide the
108
- value returned by 2.303. The value is often given in base 10 terms (0.509 at
109
- 25 degC) in older textbooks.
97
+ References:
98
+ Archer, Donald G. and Wang, Peiming. "The Dielectric Constant of Water \
99
+ and Debye-Huckel Limiting Law Slopes." /J. Phys. Chem. Ref. Data/ 19(2), 1990.
110
100
 
111
- References
112
- ----------
113
- .. [#] Archer, Donald G. and Wang, Peiming. "The Dielectric Constant of Water \
114
- and Debye-Huckel Limiting Law Slopes." /J. Phys. Chem. Ref. Data/ 19(2), 1990.
101
+ https://chem.libretexts.org/Bookshelves/Physical_and_Theoretical_Chemistry_Textbook_Maps/Physical_Chemistry_(LibreTexts)/25%3A_Solutions_II_-_Nonvolatile_Solutes/25.06%3A_The_Debye-Huckel_Theory
115
102
 
116
- Examples
117
- --------
118
- >>> _debye_parameter_activity() #doctest: +ELLIPSIS
119
- 1.17499...
103
+ https://en.wikipedia.org/wiki/Debye%E2%80%93H%C3%BCckel_equation
120
104
 
121
- See Also
122
- --------
123
- _debye_parameter_osmotic
105
+ See Also:
106
+ :func:`_debye_parameter_osmotic`
124
107
 
125
108
  """
109
+ T = ureg.Quantity(temperature)
110
+ water_substance = create_water_substance(
111
+ T,
112
+ ureg.Quantity(1, "atm"),
113
+ )
126
114
 
127
115
  debyeparam = (
128
- unit.elementary_charge ** 3
129
- * (2 * math.pi * unit.avogadro_constant * h2o.water_density(unit(temperature)))
130
- ** 0.5
131
- / (
132
- 4
133
- * math.pi
134
- * unit.epsilon_0
135
- * h2o.water_dielectric_constant(unit(temperature))
136
- * unit.boltzmann_constant
137
- * unit(temperature)
138
- )
139
- ** 1.5
116
+ ureg.elementary_charge**3
117
+ * (2 * np.pi * ureg.N_A * ureg.Quantity(water_substance.rho, "g/L")) ** 0.5
118
+ / (4 * np.pi * ureg.epsilon_0 * water_substance.epsilon * ureg.boltzmann_constant * T) ** 1.5
140
119
  )
141
120
 
142
- logger.info(
143
- "Computed Debye-Huckel Limiting Law Constant A^{\\gamma} = %s at %s"
144
- % (debyeparam, temperature)
145
- )
121
+ logger.debug(rf"Computed Debye-Huckel Limiting Law Constant A^{{\gamma}} = {debyeparam} at {temperature}")
146
122
  return debyeparam.to("kg ** 0.5 / mol ** 0.5")
147
123
 
148
124
 
149
125
  def _debye_parameter_osmotic(temperature="25 degC"):
150
- """
151
- Return the constant A_phi for use in calculating the osmotic coefficient according to Debye-Huckel theory
126
+ r"""
127
+ Return the constant A_phi for use in calculating the osmotic coefficient according to Debye-Huckel theory.
152
128
 
153
- Parameters
154
- ----------
155
- temperature : str Quantity, optional
156
- String representing the temperature of the solution. Defaults to '25 degC' if not specified.
129
+ Args:
130
+ temperature: String representing the temperature of the solution. Defaults to '25 degC' if not specified.
157
131
 
158
- Notes
159
- -----
160
- Not to be confused with the Debye-Huckel constant used for activity coefficients in the limiting law.
161
- Takes the value 0.392 at 25 C.
162
- This constant is calculated according to: [#]_ [#]_
132
+ Notes:
133
+ Not to be confused with the Debye-Huckel constant used for activity coefficients in the limiting law.
134
+ Takes the value 0.392 at 25 C.
135
+ This constant is calculated according to: [kim]_ [arch]_
163
136
 
164
- .. math:: A^{\\phi} = {1 \\over 3} A^{\\gamma}
137
+ .. math:: A^{\phi} = {1 \over 3} A^{\gamma}
165
138
 
166
- References
167
- ----------
168
- .. [#] Kim, Hee-Talk and Frederick, William Jr, 1988. "Evaluation of Pitzer Ion Interaction Parameters of Aqueous \
169
- Electrolytes at 25 C. 1. Single Salt Parameters,"
170
- *J. Chemical Engineering Data* 33, pp.177-184.
139
+ References:
140
+ .. [kim] Kim, Hee-Talk and Frederick, William Jr, 1988. "Evaluation of Pitzer Ion Interaction Parameters of Aqueous Electrolytes at 25 C. 1. Single Salt Parameters,"
141
+ *J. Chemical Engineering Data* 33, pp.177-184.
171
142
 
172
- .. [#] Archer, Donald G. and Wang, Peiming. "The Dielectric Constant of Water \
173
- and Debye-Huckel Limiting Law Slopes." /J. Phys. Chem. Ref. Data/ 19(2), 1990.
143
+ .. [arch] Archer, Donald G. and Wang, Peiming. "The Dielectric Constant of Water \
144
+ and Debye-Huckel Limiting Law Slopes." /J. Phys. Chem. Ref. Data/ 19(2), 1990.
174
145
 
175
- Examples
176
- --------
177
- >>> _debye_parameter_osmotic() #doctest: +ELLIPSIS
178
- 0.3916...
146
+ Examples:
147
+ >>> _debye_parameter_osmotic() #doctest: +ELLIPSIS
148
+ 0.3916...
179
149
 
180
- See Also
181
- --------
182
- _debye_parameter_activity
150
+ See Also:
151
+ :func:`_debye_parameter_activity`
183
152
 
184
153
  """
185
-
186
154
  output = 1 / 3 * _debye_parameter_activity(temperature)
187
- logger.info(
188
- "Computed Debye-Huckel Limiting slope for osmotic coefficient A^{\\phi} = %s at %s"
189
- % (output, temperature)
190
- )
155
+ logger.debug(f"Computed Debye-Huckel Limiting slope for osmotic coefficient A^phi = {output} at {temperature}")
191
156
  return output.to("kg ** 0.5 /mol ** 0.5")
192
157
 
193
158
 
194
159
  def _debye_parameter_volume(temperature="25 degC"):
195
- """
160
+ r"""
196
161
  Return the constant A_V, the Debye-Huckel limiting slope for apparent
197
162
  molar volume.
198
163
 
199
- Parameters
200
- ----------
201
- temperature : str Quantity, optional
202
- String representing the temperature of the solution. Defaults to '25 degC' if not specified.
164
+ Args:
165
+ temperature: String representing the temperature of the solution. Defaults to '25 degC' if not specified.
203
166
 
204
- Notes
205
- -----
206
- Takes the value 1.8305 cm ** 3 * kg ** 0.5 / mol ** 1.5 at 25 C.
207
- This constant is calculated according to: [#]_
167
+ Notes:
168
+ Takes the value 1.8305 cm ** 3 * kg ** 0.5 / mol ** 1.5 at 25 C.
169
+ This constant is calculated according to: [1]_
208
170
 
209
- .. math:: A_V = -2 A_{\\phi} R T [ {3 \\over \\epsilon} {{\\partial \\epsilon \\over \\partial p} \
210
- } - {{1 \\over \\rho}{\\partial \\rho \\over \\partial p} }]
171
+ .. math:: A_V = -2 A_{\phi} R T \big[ \frac{3}{\epsilon} \frac{\partial \epsilon}{\partial p} \
172
+ - \frac{1}{\rho}\frac{\partial \rho}{\partial p} \big]
211
173
 
212
- NOTE: at this time, the term in brackets (containing the partial derivatives) is approximate.
213
- These approximations give the correct value of the slope at 25 degC and
214
- produce estimates with less than 10% error between 0 and 60 degC.
174
+ Notes: at this time, the term in brackets (containing the partial derivatives) is approximate.
175
+ These approximations give the correct value of the slope at 25 degC and
176
+ produce estimates with less than 10% error between 0 and 60 degC.
215
177
 
216
- The derivative of epsilon with respect to pressure is assumed constant (for atmospheric pressure)
217
- at -0.01275 1/MPa. Note that the negative sign does not make sense in light
218
- of real data, but is required to give the correct result.
178
+ The derivative of epsilon with respect to pressure is assumed constant (for atmospheric pressure)
179
+ at -0.01275 1/MPa. Note that the negative sign does not make sense in light
180
+ of real data, but is required to give the correct result.
219
181
 
220
- The second term is equivalent to the inverse of the bulk modulus of water, which
221
- is taken to be 2.2 GPa. [#]_
182
+ The second term is equivalent to the inverse of the bulk modulus of water, which
183
+ is taken to be 2.2 GPa. [2]_
222
184
 
223
- References
224
- ----------
225
- .. [#] Archer, Donald G. and Wang, Peiming. "The Dielectric Constant of Water \
226
- and Debye-Huckel Limiting Law Slopes." /J. Phys. Chem. Ref. Data/ 19(2), 1990.
185
+ References:
186
+ .. [1] Archer, Donald G. and Wang, Peiming. "The Dielectric Constant of Water and Debye-Huckel Limiting
187
+ Law Slopes." J. Phys. Chem. Ref. Data/ 19(2), 1990.
227
188
 
228
- .. [#] http://hyperphysics.phy-astr.gsu.edu/hbase/permot3.html
189
+ .. [2] http://hyperphysics.phy-astr.gsu.edu/hbase/permot3.html
229
190
 
230
- Examples
231
- --------
232
- TODO
233
-
234
-
235
- See Also
236
- --------
237
- _debye_parameter_osmotic
191
+ See Also:
192
+ :func:`_debye_parameter_osmotic`
238
193
 
239
194
  """
195
+ T = ureg.Quantity(temperature)
196
+ water_substance = create_water_substance(
197
+ T,
198
+ ureg.Quantity(1, "atm"),
199
+ )
240
200
 
241
201
  # TODO - add partial derivatives to calculation
242
- epsilon = h2o.water_dielectric_constant(unit(temperature))
243
- dedp = unit("-0.01275 1/MPa")
202
+ epsilon = water_substance.epsilon
203
+ dedp = ureg.Quantity(-0.01275, "1/MPa")
244
204
  result = (
245
- -2
246
- * _debye_parameter_osmotic(temperature)
247
- * unit.R
248
- * unit(temperature)
249
- * (3 / epsilon * dedp - 1 / unit("2.2 GPa"))
205
+ -2 * _debye_parameter_osmotic(temperature) * ureg.R * T * (3 / epsilon * dedp - 1 / ureg.Quantity(2.2, "GPa"))
250
206
  )
251
- # result = unit('1.898 cm ** 3 * kg ** 0.5 / mol ** 1.5')
207
+ # result = ureg.Quantity('1.898 cm ** 3 * kg ** 0.5 / mol ** 1.5')
252
208
 
253
- if unit(temperature) != unit("25 degC"):
254
- logger.warning(
255
- "Debye-Huckel limiting slope for volume is approximate when T is not equal to 25 degC"
256
- )
209
+ if T.to("degC").magnitude != 25:
210
+ logger.warning("Debye-Huckel limiting slope for volume is approximate when T is not equal to 25 degC")
257
211
 
258
- logger.info(
259
- "Computed Debye-Huckel Limiting Slope for volume A^V = %s at %s"
260
- % (result, temperature)
261
- )
212
+ logger.debug(f"Computed Debye-Huckel Limiting Slope for volume A^V = {result} at {temperature}")
262
213
 
263
214
  return result.to("cm ** 3 * kg ** 0.5 / mol ** 1.5")
264
215
 
265
216
 
266
- def get_activity_coefficient_debyehuckel(
267
- ionic_strength, formal_charge=1, temperature="25 degC"
268
- ):
269
- """
217
+ def get_activity_coefficient_debyehuckel(ionic_strength, z=1, temperature="25 degC"):
218
+ r"""
270
219
  Return the activity coefficient of solute in the parent solution according to the Debye-Huckel limiting law.
271
220
 
272
- Parameters
273
- ----------
274
- formal_charge : int, optional
275
- The charge on the solute, including sign. Defaults to +1 if not specified.
276
- ionic_strength : Quantity
277
- The ionic strength of the parent solution, mol/kg
278
- temperature : str Quantity, optional
279
- String representing the temperature of the solution. Defaults to '25 degC' if not specified.
280
-
281
- Returns
282
- -------
283
- Quantity
284
- The mean molal (mol/kg) scale ionic activity coefficient of solute, dimensionless.
221
+ Args:
222
+ z (int, optional): The charge on the solute, including sign. Defaults to +1 if not specified.
223
+ ionic_strength (Quantity): The ionic strength of the parent solution, mol/kg.
224
+ temperature (str, Quantity, optional): String representing the temperature of the solution. Defaults to '25 degC' if not specified.
285
225
 
286
- See Also
287
- --------
288
- _debye_parameter_activity
226
+ Returns:
227
+ Quantity: The mean molal (mol/kg) scale ionic activity coefficient of solute, dimensionless.
289
228
 
290
- Notes
291
- -----
292
- Activity coefficient is calculated according to: [#]_
229
+ Notes:
230
+ Activity coefficient is calculated according to:
293
231
 
294
- .. math:: \\ln \\gamma = A^{\\gamma} z_i^2 \sqrt I
232
+ .. math:: \ln \gamma = A^{\gamma} z_i^2 \sqrt I
295
233
 
296
- Valid only for I < 0.005
234
+ Valid only for I < 0.005
297
235
 
298
- References
299
- ----------
300
- .. [#] Stumm, Werner and Morgan, James J. Aquatic Chemistry, 3rd ed, pp 103. Wiley Interscience, 1996.
236
+ See Also:
237
+ :func:`_debye_parameter_activity`
238
+ :func:`get_activity_coefficient_davies`
239
+ :func:`get_activity_coefficient_guntelberg`
301
240
 
241
+ References:
242
+ Stumm, Werner and Morgan, James J. Aquatic Chemistry, 3rd ed,
243
+ pp 103. Wiley Interscience, 1996.
302
244
  """
303
245
  # check if this method is valid for the given ionic strength
304
246
  if not ionic_strength.magnitude <= 0.005:
305
- logger.warning(
306
- "Ionic strength exceeds valid range of the Debye-Huckel limiting law"
307
- )
247
+ logger.warning("Ionic strength exceeds valid range of the Debye-Huckel limiting law")
308
248
 
309
- log_f = (
310
- -_debye_parameter_activity(temperature)
311
- * formal_charge ** 2
312
- * ionic_strength ** 0.5
313
- )
249
+ log_f = -_debye_parameter_activity(temperature) * z**2 * ionic_strength**0.5
314
250
 
315
- return math.exp(log_f) * unit("1 dimensionless")
251
+ return np.exp(log_f) * ureg.Quantity(1, "dimensionless")
316
252
 
317
253
 
318
- def get_activity_coefficient_guntelberg(
319
- ionic_strength, formal_charge=1, temperature="25 degC"
320
- ):
321
- """
254
+ def get_activity_coefficient_guntelberg(ionic_strength, z=1, temperature="25 degC"):
255
+ r"""
322
256
  Return the activity coefficient of solute in the parent solution according to the Guntelberg approximation.
323
257
 
324
- Parameters
325
- ----------
326
- formal_charge : int, optional
327
- The charge on the solute, including sign. Defaults to +1 if not specified.
328
- ionic_strength : Quantity
329
- The ionic strength of the parent solution, mol/kg
330
- temperature : str Quantity, optional
331
- String representing the temperature of the solution. Defaults to '25 degC' if not specified.
258
+ Args:
259
+ z (int, optional): The charge on the solute, including sign. Defaults to +1 if not specified.
260
+ ionic_strength (Quantity): The ionic strength of the parent solution, mol/kg.
261
+ temperature (str, Quantity, optional): String representing the temperature of the solution. Defaults to '25 degC' if not specified.
332
262
 
333
- Returns
334
- -------
335
- Quantity
336
- The mean molal (mol/kg) scale ionic activity coefficient of solute, dimensionless.
263
+ Returns:
264
+ Quantity: The mean molal (mol/kg) scale ionic activity coefficient of solute, dimensionless.
337
265
 
338
- See Also
339
- --------
340
- _debye_parameter_activity
266
+ Notes:
267
+ Activity coefficient is calculated according to:
341
268
 
342
- Notes
343
- ------
344
- Activity coefficient is calculated according to: [#]_
269
+ .. math:: \ln \gamma = A^{\gamma} z_i^2 {\sqrt I \over (1 + \sqrt I)}
345
270
 
346
- .. math:: \\ln \\gamma = A^{\\gamma} z_i^2 {\sqrt I \\over (1 + \sqrt I)}
271
+ Valid for I < 0.1
347
272
 
348
- Valid for I < 0.1
349
-
350
- References
351
- ----------
352
- .. [#] Stumm, Werner and Morgan, James J. Aquatic Chemistry, 3rd ed, pp 103. Wiley Interscience, 1996.
273
+ See Also:
274
+ :func:`_debye_parameter_activity`
275
+ :func:`get_activity_coefficient_davies`
276
+ :func:`get_activity_coefficient_debyehuckel`
353
277
 
278
+ References:
279
+ Stumm, Werner and Morgan, James J. Aquatic Chemistry, 3rd ed,
280
+ pp 103. Wiley Interscience, 1996.
354
281
  """
355
282
  # check if this method is valid for the given ionic strength
356
283
  if not ionic_strength.magnitude <= 0.1:
357
- logger.warning(
358
- "Ionic strength exceeds valid range of the Guntelberg approximation"
359
- )
284
+ logger.warning("Ionic strength exceeds valid range of the Guntelberg approximation")
360
285
 
361
- log_f = (
362
- -_debye_parameter_activity(temperature)
363
- * formal_charge ** 2
364
- * ionic_strength ** 0.5
365
- / (1 + ionic_strength.magnitude ** 0.5)
366
- )
286
+ log_f = -_debye_parameter_activity(temperature) * z**2 * ionic_strength**0.5 / (1 + ionic_strength.magnitude**0.5)
367
287
 
368
- return math.exp(log_f) * unit("1 dimensionless")
288
+ return np.exp(log_f) * ureg.Quantity(1, "dimensionless")
369
289
 
370
290
 
371
- def get_activity_coefficient_davies(
372
- ionic_strength, formal_charge=1, temperature="25 degC"
373
- ):
374
- """
291
+ def get_activity_coefficient_davies(ionic_strength, z=1, temperature="25 degC"):
292
+ r"""
375
293
  Return the activity coefficient of solute in the parent solution according to the Davies equation.
376
294
 
377
- Parameters
378
- ----------
379
- formal_charge : int, optional
380
- The charge on the solute, including sign. Defaults to +1 if not specified.
381
- ionic_strength : Quantity
382
- The ionic strength of the parent solution, mol/kg
383
- temperature : str Quantity, optional
384
- String representing the temperature of the solution. Defaults to '25 degC' if not specified.
385
-
386
- Returns
387
- -------
388
- Quantity
389
- The mean molal (mol/kg) scale ionic activity coefficient of solute, dimensionless.
295
+ Args:
296
+ ionic_strength (Quantity): The ionic strength of the parent solution, mol/kg.
297
+ z (int, optional): The charge on the solute, including sign. Defaults to +1 if not specified.
298
+ temperature (str, Quantity, optional): String representing the temperature of the solution. Defaults to '25 degC' if not specified.
390
299
 
391
- See Also
392
- --------
393
- _debye_parameter_activity
300
+ Returns:
301
+ Quantity: The mean molal (mol/kg) scale ionic activity coefficient of solute, dimensionless.
394
302
 
395
- Notes
396
- -----
397
- Activity coefficient is calculated according to: [#]_
303
+ Notes:
304
+ Activity coefficient is calculated according to:
398
305
 
399
- .. math:: \\ln \\gamma = A^{\\gamma} z_i^2 ({\sqrt I \\over (1 + \sqrt I)} + 0.2 I)
306
+ .. math:: \ln \gamma = A^{\gamma} z_i^2 ({\sqrt I \over (1 + \sqrt I)} + 0.2 I)
400
307
 
401
- Valid for 0.1 < I < 0.5
308
+ Valid for 0.1 < I < 0.5
402
309
 
403
- References
404
- ----------
405
- .. [#] Stumm, Werner and Morgan, James J. Aquatic Chemistry, 3rd ed, pp 103. Wiley Interscience, 1996.
310
+ See Also:
311
+ :func:`_debye_parameter_activity`
312
+ :func:`get_activity_coefficient_debyehuckel`
313
+ :func:`get_activity_coefficient_guntelberg`
406
314
 
315
+ References:
316
+ Stumm, Werner and Morgan, James J. Aquatic Chemistry, 3rd ed,
317
+ pp 103. Wiley Interscience, 1996.
407
318
  """
408
319
  # check if this method is valid for the given ionic strength
409
320
  if not ionic_strength.magnitude <= 0.5 and ionic_strength.magnitude >= 0.1:
@@ -412,14 +323,11 @@ def get_activity_coefficient_davies(
412
323
  # the units in this empirical equation don't work out, so we must use magnitudes
413
324
  log_f = (
414
325
  -_debye_parameter_activity(temperature).magnitude
415
- * formal_charge ** 2
416
- * (
417
- ionic_strength.magnitude ** 0.5 / (1 + ionic_strength.magnitude ** 0.5)
418
- - 0.2 * ionic_strength.magnitude
419
- )
326
+ * z**2
327
+ * (ionic_strength.magnitude**0.5 / (1 + ionic_strength.magnitude**0.5) - 0.2 * ionic_strength.magnitude)
420
328
  )
421
329
 
422
- return math.exp(log_f) * unit("1 dimensionless")
330
+ return np.exp(log_f) * ureg.Quantity(1, "dimensionless")
423
331
 
424
332
 
425
333
  def get_activity_coefficient_pitzer(
@@ -441,102 +349,79 @@ def get_activity_coefficient_pitzer(
441
349
  """
442
350
  Return the activity coefficient of solute in the parent solution according to the Pitzer model.
443
351
 
444
- Parameters
445
- ----------
446
- ionic_strength: Quantity
447
- The ionic strength of the parent solution, mol/kg
448
- molality: Quantity
449
- The molal concentration of the parent salt, mol/kg
450
- alpha1, alpha2: number
451
- Coefficients for the Pitzer model. This function assigns the coefficients
452
- proper units of kg ** 0.5 / mol ** 0.5 after they are entered.
453
- beta0, beta1, beta2, C_phi: number
454
- Coefficients for the Pitzer model. These ion-interaction parameters are
455
- specific to each salt system.
456
- z_cation, z_anion: int
457
- The formal charge on the cation and anion, respectively
458
- nu_cation, nu_anion: int
459
- The stoichiometric coefficient of the cation and anion in the salt
460
- temperature: str Quantity
461
- String representing the temperature of the solution. Defaults to '25 degC' if not specified.
462
- b: number, optional
463
- Coefficient. Usually set equal to 1.2 and
464
- considered independent of temperature and pressure. If provided, this
465
- coefficient is assigned proper units of kg ** 0.5 / mol ** 0.5 after
466
- entry.
467
-
468
- Returns
469
- -------
470
- Quantity
471
- The mean molal (mol/kg) scale ionic activity coefficient of solute, dimensionless
472
-
473
- Examples
474
- --------
475
- >>> get_activity_coefficient_pitzer(0.5*unit('mol/kg'),0.5*unit('mol/kg'),1,0.5,-.0181191983,-.4625822071,.4682,.000246063,1,-1,1,1,b=1.2)
476
- 0.61915...
477
-
478
- >>> get_activity_coefficient_pitzer(5.6153*unit('mol/kg'),5.6153*unit('mol/kg'),3,0.5,0.0369993,0.354664,0.0997513,-0.00171868,1,-1,1,1,b=1.2)
479
- 0.76331...
480
-
481
- NOTE: the examples below are for comparison with experimental and modeling data presented in
482
- the May et al reference below.
483
-
484
- 10 mol/kg ammonium nitrate. Estimated result (from graph) = 0.2725
485
-
486
- >>> get_activity_coefficient_pitzer(10*unit('mol/kg'),10*unit('mol/kg'),2,0,-0.01709,0.09198,0,0.000419,1,-1,1,1,b=1.2)
487
- 0.22595 ...
488
-
489
- 5 mol/kg ammonium nitrate. Estimated result (from graph) = 0.3011
490
-
491
- >>> get_activity_coefficient_pitzer(5*unit('mol/kg'),5*unit('mol/kg'),2,0,-0.01709,0.09198,0,0.000419,1,-1,1,1,b=1.2)
492
- 0.30249 ...
493
-
494
- 18 mol/kg ammonium nitrate. Estimated result (from graph) = 0.1653
495
-
496
- >>> get_activity_coefficient_pitzer(18*unit('mol/kg'),18*unit('mol/kg'),2,0,-0.01709,0.09198,0,0.000419,1,-1,1,1,b=1.2)
497
- 0.16241 ...
498
-
499
- References
500
- ----------
501
- Scharge, T., Munoz, A.G., and Moog, H.C. (2012). Activity Coefficients of Fission Products in Highly
502
- Salinary Solutions of Na+, K+, Mg2+, Ca2+, Cl-, and SO42- : Cs+.
503
- /Journal of Chemical& Engineering Data (57), p. 1637-1647.
504
-
505
- Kim, H., & Jr, W. F. (1988). Evaluation of Pitzer ion interaction parameters of aqueous electrolytes at 25 degree C.
506
- 1. Single salt parameters.
507
- Journal of Chemical and Engineering Data, (2), 177–184.
508
-
509
- May, P. M., Rowland, D., Hefter, G., & Königsberger, E. (2011).
510
- A Generic and Updatable Pitzer Characterization of Aqueous Binary Electrolyte Solutions at 1 bar and 25 °C.
511
- Journal of Chemical & Engineering Data, 56(12), 5066–5077. doi:10.1021/je2009329
512
-
513
- Beyer, R., & Steiger, M. (2010). Vapor Pressure Measurements of NaHCOO + H 2 O and KHCOO + H 2 O from 278 to 308 K
514
- and Representation with an Ion Interaction (Pitzer) Model.
515
- Journal of Chemical & Engineering Data, 55(2), 830–838. doi:10.1021/je900487a
516
-
517
- See Also
518
- --------
519
- _debye_parameter_activity
520
- _pitzer_B_MX
521
- _pitzer_B_gamma
522
- _pitzer_B_phi
523
- _pitzer_log_gamma
352
+ Args:
353
+ ionic_strength: The ionic strength of the parent solution, mol/kg
354
+ molality: The molal concentration of the parent salt, mol/kg
355
+ alpha1, alpha2: Coefficients for the Pitzer model. This function assigns the coefficients
356
+ proper units of kg ** 0.5 / mol ** 0.5 after they are entered.
357
+ beta0, beta1, beta2, C_phi: Coefficients for the Pitzer model. These ion-interaction parameters are
358
+ specific to each salt system.
359
+ z_cation, z_anion: The charge on the cation and anion, respectively
360
+ nu_cation, nu_anion: The stoichiometric coefficient of the cation and anion in the salt
361
+ temperature: String representing the temperature of the solution. Defaults to '25 degC' if not specified.
362
+ b: Coefficient. Usually set equal to 1.2 and considered independent of temperature and pressure.
363
+ If provided, this coefficient is assigned proper units of kg ** 0.5 / mol ** 0.5 after entry.
364
+
365
+ Returns:
366
+ Quantity
367
+ The mean molal (mol/kg) scale ionic activity coefficient of solute, dimensionless
368
+
369
+ Examples:
370
+ >>> get_activity_coefficient_pitzer(0.5*ureg.Quantity('mol/kg'),0.5*ureg.Quantity('mol/kg'),1,0.5,-.0181191983,-.4625822071,.4682,.000246063,1,-1,1,1,b=1.2)
371
+ 0.61915...
372
+
373
+ >>> get_activity_coefficient_pitzer(5.6153*ureg.Quantity('mol/kg'),5.6153*ureg.Quantity('mol/kg'),3,0.5,0.0369993,0.354664,0.0997513,-0.00171868,1,-1,1,1,b=1.2)
374
+ 0.76331...
524
375
 
376
+ Notes: the examples below are for comparison with experimental and modeling data presented in
377
+ the May et al reference below.
525
378
 
379
+ 10 mol/kg ammonium nitrate. Estimated result (from graph) = 0.2725
380
+
381
+ >>> get_activity_coefficient_pitzer(10*ureg.Quantity('mol/kg'),10*ureg.Quantity('mol/kg'),2,0,-0.01709,0.09198,0,0.000419,1,-1,1,1,b=1.2)
382
+ 0.22595 ...
383
+
384
+ 5 mol/kg ammonium nitrate. Estimated result (from graph) = 0.3011
385
+
386
+ >>> get_activity_coefficient_pitzer(5*ureg.Quantity('mol/kg'),5*ureg.Quantity('mol/kg'),2,0,-0.01709,0.09198,0,0.000419,1,-1,1,1,b=1.2)
387
+ 0.30249 ...
388
+
389
+ 18 mol/kg ammonium nitrate. Estimated result (from graph) = 0.1653
390
+
391
+ >>> get_activity_coefficient_pitzer(18*ureg.Quantity('mol/kg'),18*ureg.Quantity('mol/kg'),2,0,-0.01709,0.09198,0,0.000419,1,-1,1,1,b=1.2)
392
+ 0.16241 ...
393
+
394
+ References:
395
+ Scharge, T., Munoz, A.G., and Moog, H.C. (2012). Activity Coefficients of Fission Products in Highly
396
+ Salinary Solutions of Na+, K+, Mg2+, Ca2+, Cl-, and SO42- : Cs+.
397
+ /Journal of Chemical& Engineering Data (57), p. 1637-1647.
398
+
399
+ Kim, H., & Jr, W. F. (1988). Evaluation of Pitzer ion interaction parameters of aqueous electrolytes at 25 degree C. 1. Single salt parameters.
400
+ Journal of Chemical and Engineering Data, (2), 177-184.
401
+
402
+ May, P. M., Rowland, D., Hefter, G., & Königsberger, E. (2011).
403
+ A Generic and Updatable Pitzer Characterization of Aqueous Binary Electrolyte Solutions at 1 bar and 25 °C.
404
+ Journal of Chemical & Engineering Data, 56(12), 5066-5077. doi:10.1021/je2009329
405
+
406
+ Beyer, R., & Steiger, M. (2010). Vapor Pressure Measurements of NaHCOO + H 2 O and KHCOO + H 2 O from 278 to 308 K
407
+ and Representation with an Ion Interaction (Pitzer) Model.
408
+ Journal of Chemical & Engineering Data, 55(2), 830-838. doi:10.1021/je900487a
409
+
410
+ See Also:
411
+ :func:`_debye_parameter_activity`
412
+ :func:`_pitzer_B_MX`
413
+ :func:`_pitzer_B_phi`
414
+ :func:`_pitzer_log_gamma`
526
415
  """
527
416
  # assign proper units to alpha1, alpha2, and b
528
- alpha1 = alpha1 * unit("kg ** 0.5 / mol ** 0.5")
529
- alpha2 = alpha2 * unit("kg ** 0.5 / mol ** 0.5")
530
- b = b * unit("kg ** 0.5 / mol ** 0.5")
531
- C_phi = C_phi * unit("kg ** 2 /mol ** 2")
417
+ alpha1 = ureg.Quantity(alpha1, "kg ** 0.5 / mol ** 0.5")
418
+ alpha2 = ureg.Quantity(alpha2, "kg ** 0.5 / mol ** 0.5")
419
+ b = ureg.Quantity(b, "kg ** 0.5 / mol ** 0.5")
420
+ C_phi = ureg.Quantity(C_phi, "kg ** 2 /mol ** 2")
532
421
 
533
422
  # assign units appropriate for the activity parameters
534
- BMX = _pitzer_B_MX(ionic_strength, alpha1, alpha2, beta0, beta1, beta2) * unit(
535
- "kg/mol"
536
- )
537
- Bphi = _pitzer_B_phi(ionic_strength, alpha1, alpha2, beta0, beta1, beta2) * unit(
538
- "kg/mol"
539
- )
423
+ BMX = ureg.Quantity(_pitzer_B_MX(ionic_strength, alpha1, alpha2, beta0, beta1, beta2), "kg/mol")
424
+ Bphi = ureg.Quantity(_pitzer_B_phi(ionic_strength, alpha1, alpha2, beta0, beta1, beta2), "kg/mol")
540
425
 
541
426
  loggamma = _pitzer_log_gamma(
542
427
  ionic_strength,
@@ -552,7 +437,7 @@ def get_activity_coefficient_pitzer(
552
437
  b,
553
438
  )
554
439
 
555
- return math.exp(loggamma) * unit("1 dimensionless")
440
+ return np.exp(loggamma) * ureg.Quantity(1, "dimensionless")
556
441
 
557
442
 
558
443
  def get_apparent_volume_pitzer(
@@ -575,115 +460,88 @@ def get_apparent_volume_pitzer(
575
460
  """
576
461
  Return the apparent molar volume of solute in the parent solution according to the Pitzer model.
577
462
 
578
- Parameters
579
- ----------
580
- ionic_strength: Quantity
581
- The ionic strength of the parent solution, mol/kg
582
- molality: Quantity
583
- The molal concentration of the parent salt, mol/kg
584
- alpha1, alpha2: number
585
- Coefficients for the Pitzer model. This function assigns the coefficients
586
- proper units of kg ** 0.5 / mol ** 0.5 after they are entered.
587
- beta0, beta1, beta2, C_phi: number
588
- Pitzer coefficients for the apparent molar volume.
589
- These ion-interaction parameters are specific to each salt system.
590
- V_o: number
591
- The V^o Pitzer coefficient for the apparent molar volume.
592
- z_cation, z_anion: int
593
- The formal charge on the cation and anion, respectively
594
- nu_cation, nu_anion: int
595
- The stoichiometric coefficient of the cation and anion in the salt
596
- temperature: str Quantity
597
- String representing the temperature of the solution. Defaults to '25 degC' if not specified.
598
- b: number, optional
599
- Coefficient. Usually set equal to 1.2 and
600
- considered independent of temperature and pressure. If provided, this
601
- coefficient is assigned proper units of kg ** 0.5 / mol ** 0.5 after
602
- entry.
463
+ Args:
464
+ ionic_strength (Quantity): The ionic strength of the parent solution, mol/kg.
465
+ molality (Quantity): The molal concentration of the parent salt, mol/kg.
466
+ alpha1, alpha2 (number): Coefficients for the Pitzer model. This function assigns the coefficients proper units of kg ** 0.5 / mol ** 0.5 after they are entered.
467
+ beta0, beta1, beta2, C_phi (number): Pitzer coefficients for the apparent molar volume. These ion-interaction parameters are specific to each salt system.
468
+ V_o (number): The V^o Pitzer coefficient for the apparent molar volume.
469
+ z_cation, z_anion (int): The formal charge on the cation and anion, respectively.
470
+ nu_cation, nu_anion (int): The stoichiometric coefficient of the cation and anion in the salt.
471
+ temperature (str, Quantity): String representing the temperature of the solution. Defaults to '25 degC' if not specified.
472
+ b (number, optional): Coefficient. Usually set equal to 1.2 and considered independent of temperature and pressure. If provided, this coefficient is assigned proper units of kg ** 0.5 / mol ** 0.5 after entry.
603
473
 
604
- Returns
605
- -------
606
- Quantity
607
- The apparent molar volume of the solute, cm ** 3 / mol
474
+ Returns:
475
+ Quantity: The apparent molar volume of the solute, cm ** 3 / mol.
608
476
 
609
- Examples
610
- --------
611
- NOTE: the example below is for comparison with experimental and modeling data presented in
612
- the Krumgalz et al reference below.
477
+ Examples:
478
+ Notes: the example below is for comparison with experimental and modeling data presented in the Krumgalz et al reference below.
613
479
 
614
- 0.25 mol/kg CuSO4. Expected result (from graph) = 0.5 cm ** 3 / mol
480
+ 0.25 mol/kg CuSO4. Expected result (from graph) = 0.5 cm ** 3 / mol
615
481
 
616
- >>> get_apparent_volume_pitzer(1.0*unit('mol/kg'),0.25*unit('mol/kg'),1.4,12,0.001499,-0.008124,0.2203,-0.0002589,-6,2,-2,1,1,b=1.2)
617
- 0.404...
482
+ >>> get_apparent_volume_pitzer(1.0*ureg.Quantity('mol/kg'),0.25*ureg.Quantity('mol/kg'),1.4,12,0.001499,-0.008124,0.2203,-0.0002589,-6,2,-2,1,1,b=1.2)
483
+ 0.404...
618
484
 
619
- 1.0 mol/kg CuSO4. Expected result (from graph) = 4 cm ** 3 / mol
485
+ 1.0 mol/kg CuSO4. Expected result (from graph) = 4 cm ** 3 / mol
620
486
 
621
- >>> get_apparent_volume_pitzer(4.0*unit('mol/kg'),1.0*unit('mol/kg'),1.4,12,0.001499,-0.008124,0.2203,-0.0002589,-6,2,-2,1,1,b=1.2)
622
- 4.424...
487
+ >>> get_apparent_volume_pitzer(4.0*ureg.Quantity('mol/kg'),1.0*ureg.Quantity('mol/kg'),1.4,12,0.001499,-0.008124,0.2203,-0.0002589,-6,2,-2,1,1,b=1.2)
488
+ 4.424...
623
489
 
624
- 10.0 mol/kg ammonium nitrate. Expected result (from graph) = 50.3 cm ** 3 / mol
490
+ 10.0 mol/kg ammonium nitrate. Expected result (from graph) = 50.3 cm ** 3 / mol
625
491
 
626
- >>> get_apparent_volume_pitzer(10.0*unit('mol/kg'),10.0*unit('mol/kg'),2,0,0.000001742,0.0002926,0,0.000000424,46.9,1,-1,1,1,b=1.2)
627
- 50.286...
492
+ >>> get_apparent_volume_pitzer(10.0*ureg.Quantity('mol/kg'),10.0*ureg.Quantity('mol/kg'),2,0,0.000001742,0.0002926,0,0.000000424,46.9,1,-1,1,1,b=1.2)
493
+ 50.286...
628
494
 
629
- 20.0 mol/kg ammonium nitrate. Expected result (from graph) = 51.2 cm ** 3 / mol
495
+ 20.0 mol/kg ammonium nitrate. Expected result (from graph) = 51.2 cm ** 3 / mol
630
496
 
631
- >>> get_apparent_volume_pitzer(20.0*unit('mol/kg'),20.0*unit('mol/kg'),2,0,0.000001742,0.0002926,0,0.000000424,46.9,1,-1,1,1,b=1.2)
632
- 51.145...
497
+ >>> get_apparent_volume_pitzer(20.0*ureg.Quantity('mol/kg'),20.0*ureg.Quantity('mol/kg'),2,0,0.000001742,0.0002926,0,0.000000424,46.9,1,-1,1,1,b=1.2)
498
+ 51.145...
633
499
 
634
- NOTE: the examples below are for comparison with experimental and modeling data presented in
635
- the Krumgalz et al reference below.
500
+ Notes: the examples below are for comparison with experimental and modeling data presented in the Krumgalz et al reference below.
636
501
 
637
- 0.8 mol/kg NaF. Expected result = 0.03
502
+ 0.8 mol/kg NaF. Expected result = 0.03
638
503
 
639
- >>> get_apparent_volume_pitzer(0.8*unit('mol/kg'),0.8*unit('mol/kg'),2,0,0.000024693,0.00003169,0,-0.000004068,-2.426,1,-1,1,1,b=1.2)
640
- 0.22595 ...
504
+ >>> get_apparent_volume_pitzer(0.8*ureg.Quantity('mol/kg'),0.8*ureg.Quantity('mol/kg'),2,0,0.000024693,0.00003169,0,-0.000004068,-2.426,1,-1,1,1,b=1.2)
505
+ 0.22595 ...
641
506
 
507
+ References:
508
+ May, P. M., Rowland, D., Hefter, G., & Königsberger, E. (2011).
509
+ A Generic and Updatable Pitzer Characterization of Aqueous Binary Electrolyte Solutions at 1 bar and 25 °C.
510
+ Journal of Chemical & Engineering Data, 56(12), 5066-5077. doi:10.1021/je2009329
642
511
 
643
- References
644
- ----------
645
- May, P. M., Rowland, D., Hefter, G., & Königsberger, E. (2011).
646
- A Generic and Updatable Pitzer Characterization of Aqueous Binary Electrolyte Solutions at 1 bar and 25 °C.
647
- Journal of Chemical & Engineering Data, 56(12), 5066–5077. doi:10.1021/je2009329
648
-
649
- Krumgalz, Boris S., Pogorelsky, Rita (1996).
650
- Volumetric Properties of Single Aqueous Electrolytes from Zero to Saturation Concentration at 298.15 K
651
- Represented by Pitzer's Ion-Interaction Equations.
652
- Journal of Physical Chemical Reference Data, 25(2), 663-689.
653
-
654
- See Also
655
- --------
656
- _debye_parameter_volume
657
- _pitzer_B_MX
658
-
512
+ Krumgalz, Boris S., Pogorelsky, Rita (1996).
513
+ Volumetric Properties of Single Aqueous Electrolytes from Zero to Saturation Concentration at 298.15 K
514
+ Represented by Pitzer's Ion-Interaction Equations.
515
+ Journal of Physical Chemical Reference Data, 25(2), 663-689.
659
516
 
517
+ See Also:
518
+ :func:`_debye_parameter_volume`
519
+ :func:`_pitzer_B_MX`
660
520
  """
661
521
  # TODO - find a cleaner way to make sure coefficients are assigned the proper units
662
522
  # if they aren't, the calculation gives very wrong results
663
- alpha1 = alpha1 * unit("kg ** 0.5 / mol ** 0.5")
664
- alpha2 = alpha2 * unit("kg ** 0.5 / mol ** 0.5")
665
- b = b * unit("kg ** 0.5 / mol ** 0.5")
666
- C_phi = C_phi * unit("kg ** 2 /mol ** 2 / dabar")
667
- V_o = V_o * unit("cm ** 3 / mol")
523
+ alpha1 = ureg.Quantity(alpha1, "kg ** 0.5 / mol ** 0.5")
524
+ alpha2 = ureg.Quantity(alpha2, "kg ** 0.5 / mol ** 0.5")
525
+ b = ureg.Quantity(b, "kg ** 0.5 / mol ** 0.5")
526
+ C_phi = ureg.Quantity(C_phi, "kg ** 2 /mol ** 2 / dabar")
527
+ V_o = ureg.Quantity(V_o, "cm ** 3 / mol")
668
528
 
669
529
  # assign units appropriate for the volume parameter
670
- BMX = _pitzer_B_MX(ionic_strength, alpha1, alpha2, beta0, beta1, beta2) * unit(
671
- "kg /mol/dabar"
672
- )
530
+ BMX = ureg.Quantity(_pitzer_B_MX(ionic_strength, alpha1, alpha2, beta0, beta1, beta2), "kg /mol/dabar")
673
531
 
674
532
  second_term = (
675
533
  (nu_cation + nu_anion)
676
534
  * abs(z_cation * z_anion)
677
535
  * (_debye_parameter_volume(temperature) / 2 / b)
678
- * math.log((1 + b * ionic_strength ** 0.5))
536
+ * np.log(1 + b * ionic_strength**0.5)
679
537
  )
680
538
 
681
539
  third_term = (
682
540
  nu_cation
683
541
  * nu_anion
684
- * unit.R
685
- * unit(temperature)
686
- * (2 * molality * BMX + molality ** 2 * C_phi * (nu_cation * nu_anion) ** 0.5)
542
+ * ureg.R
543
+ * ureg.Quantity(temperature)
544
+ * (2 * molality * BMX + molality**2 * C_phi * (nu_cation * nu_anion) ** 0.5)
687
545
  )
688
546
 
689
547
  volume = V_o + second_term + third_term
@@ -692,91 +550,73 @@ def get_apparent_volume_pitzer(
692
550
 
693
551
 
694
552
  def _pitzer_f1(x):
695
- """
696
- The function of ionic strength used to calculate \beta_MX in the Pitzer ion intercation model.
553
+ r"""
554
+ The function of ionic strength used to calculate \beta_MX in the Pitzer ion interaction model.
697
555
 
698
556
  .. math:: f(x) = 2 [ 1- (1+x) \exp(-x)] / x ^ 2
699
557
 
700
- References
701
- ----------
702
- Scharge, T., Munoz, A.G., and Moog, H.C. (2012). Activity Coefficients of Fission Products in Highly
703
- Salinary Solutions of Na+, K+, Mg2+, Ca2+, Cl-, and SO42- : Cs+.
704
- /Journal of Chemical& Engineering Data (57), p. 1637-1647.
705
-
706
- Kim, H., & Jr, W. F. (1988). Evaluation of Pitzer ion interaction parameters of aqueous electrolytes at 25 degree C.
707
- 1. Single salt parameters. Journal of Chemical and Engineering Data, (2), 177–184.
558
+ References:
559
+ Scharge, T., Munoz, A.G., and Moog, H.C. (2012). Activity Coefficients of Fission Products in Highly
560
+ Salinary Solutions of Na+, K+, Mg2+, Ca2+, Cl-, and SO42- : Cs+.
561
+ /Journal of Chemical& Engineering Data (57), p. 1637-1647.
708
562
 
563
+ Kim, H., & Jr, W. F. (1988). Evaluation of Pitzer ion interaction parameters of aqueous electrolytes at 25 degree C. 1. Single salt parameters.
564
+ Journal of Chemical and Engineering Data, (2), 177-184.
709
565
  """
710
566
  # return 0 if the input is 0
711
567
  if x == 0:
712
568
  return 0
713
- else:
714
- return 2 * (1 - (1 + x) * math.exp(-x)) / x ** 2
569
+ return 2 * (1 - (1 + x) * np.exp(-x)) / x**2
715
570
 
716
571
 
717
572
  def _pitzer_f2(x):
718
- """
719
- The function of ionic strength used to calculate \beta_\gamma in the Pitzer ion intercation model.
720
-
721
- .. math:: f(x) = -{2 \\over x ^ 2} [ 1 - ({1+x+ x^2 \\over 2}) \\exp(-x)]
573
+ r"""
574
+ The function of ionic strength used to calculate \beta_\gamma in the Pitzer ion interaction model.
722
575
 
723
- References
724
- ----------
725
- Scharge, T., Munoz, A.G., and Moog, H.C. (2012). Activity Coefficients of Fission Products in Highly
726
- Salinary Solutions of Na+, K+, Mg2+, Ca2+, Cl-, and SO42- : Cs+.
727
- /Journal of Chemical& Engineering Data (57), p. 1637-1647.
576
+ .. math:: f(x) = -\frac{2}{x ^ 2} [ 1 - (\frac{1+x+ x^2}{2}) \exp(-x)]
728
577
 
729
- Kim, H., & Jr, W. F. (1988). Evaluation of Pitzer ion interaction parameters of aqueous electrolytes at 25 degree C.
730
- 1. Single salt parameters. Journal of Chemical and Engineering Data, (2), 177–184.
578
+ References:
579
+ Scharge, T., Munoz, A.G., and Moog, H.C. (2012). Activity Coefficients of Fission Products in Highly
580
+ Salinary Solutions of Na+, K+, Mg2+, Ca2+, Cl-, and SO42- : Cs+.
581
+ /Journal of Chemical& Engineering Data (57), p. 1637-1647.
731
582
 
583
+ Kim, H., & Jr, W. F. (1988). Evaluation of Pitzer ion interaction parameters of aqueous electrolytes at 25 degree C. 1. Single salt parameters.
584
+ Journal of Chemical and Engineering Data, (2), 177-184.
732
585
  """
733
586
  # return 0 if the input is 0
734
587
  if x == 0:
735
588
  return 0
736
- else:
737
- return -2 * (1 - (1 + x + x ** 2 / 2) * math.exp(-x)) / x ** 2
589
+ return -2 * (1 - (1 + x + x**2 / 2) * np.exp(-x)) / x**2
738
590
 
739
591
 
740
592
  def _pitzer_B_MX(ionic_strength, alpha1, alpha2, beta0, beta1, beta2):
741
- """
593
+ r"""
742
594
  Return the B_MX coefficient for the Pitzer ion interaction model.
743
595
 
744
- .. math:: B_MX = \\beta_0 + \\beta_1 f1(\\alpha_1 I ^ {0.5}) + \\beta_2 f2(\\alpha_2 I ^ {0.5})
596
+ .. math:: B_MX = \beta_0 + \beta_1 f1(\alpha_1 I ^ {0.5}) + \beta_2 f2(\alpha_2 I ^ {0.5})
745
597
 
746
- Parameters
747
- ----------
748
- ionic_strength: number
749
- The ionic strength of the parent solution, mol/kg
750
- alpha1, alpha2: number
751
- Coefficients for the Pitzer model, kg ** 0.5 / mol ** 0.5
752
- beta0, beta1, beta2: number
753
- Coefficients for the Pitzer model. These ion-interaction parameters are
754
- specific to each salt system.
598
+ Args:
599
+ ionic_strength: The ionic strength of the parent solution, mol/kg
600
+ alpha1, alpha2: Coefficients for the Pitzer model, kg ** 0.5 / mol ** 0.5
601
+ beta0, beta1, beta2: Coefficients for the Pitzer model. These ion-interaction parameters are
602
+ specific to each salt system.
755
603
 
756
- Returns
757
- -------
758
- float
759
- The B_MX parameter for the Pitzer ion interaction model.
604
+ Returns:
605
+ The B_MX parameter for the Pitzer ion interaction model.
760
606
 
761
- References
762
- ----------
763
- Scharge, T., Munoz, A.G., and Moog, H.C. (2012). Activity Coefficients of Fission Products in Highly
764
- Salinary Solutions of Na+, K+, Mg2+, Ca2+, Cl-, and SO42- : Cs+.
765
- /Journal of Chemical& Engineering Data (57), p. 1637-1647.
607
+ References:
608
+ Scharge, T., Munoz, A.G., and Moog, H.C. (2012). Activity Coefficients of Fission Products in Highly
609
+ Salinary Solutions of Na+, K+, Mg2+, Ca2+, Cl-, and SO42- : Cs+.
610
+ /Journal of Chemical& Engineering Data (57), p. 1637-1647.
766
611
 
767
- Kim, H., & Jr, W. F. (1988). Evaluation of Pitzer ion interaction parameters of aqueous electrolytes at 25 degree C.
768
- 1. Single salt parameters. Journal of Chemical and Engineering Data, (2), 177184.
612
+ Kim, H., & Jr, W. F. (1988). Evaluation of Pitzer ion interaction parameters of aqueous electrolytes at 25 degree C. 1. Single salt parameters.
613
+ Journal of Chemical and Engineering Data, (2), 177-184.
769
614
 
770
- See Also
771
- --------
772
- _pitzer_f1
615
+ See Also:
616
+ :func:`_pitzer_f1`
773
617
 
774
618
  """
775
- coeff = (
776
- beta0
777
- + beta1 * _pitzer_f1(alpha1 * ionic_strength ** 0.5)
778
- + beta2 * _pitzer_f1(alpha2 * ionic_strength ** 0.5)
779
- )
619
+ coeff = beta0 + beta1 * _pitzer_f1(alpha1 * ionic_strength**0.5) + beta2 * _pitzer_f1(alpha2 * ionic_strength**0.5)
780
620
  return coeff.magnitude
781
621
 
782
622
 
@@ -808,7 +648,7 @@ def _pitzer_B_MX(ionic_strength, alpha1, alpha2, beta0, beta1, beta2):
808
648
  # /Journal of Chemical& Engineering Data (57), p. 1637-1647.
809
649
  #
810
650
  # Kim, H., & Jr, W. F. (1988). Evaluation of Pitzer ion interaction parameters of aqueous electrolytes at 25 degree C. 1. Single salt parameters.
811
- # Journal of Chemical and Engineering Data, (2), 177184.
651
+ # Journal of Chemical and Engineering Data, (2), 177-184.
812
652
  #
813
653
  # See Also
814
654
  # --------
@@ -816,54 +656,47 @@ def _pitzer_B_MX(ionic_strength, alpha1, alpha2, beta0, beta1, beta2):
816
656
  #
817
657
  # '''
818
658
  # coeff = (beta1 * _pitzer_f2(alpha1 * ionic_strength ** 0.5) + beta2 * _pitzer_f2(alpha2 * ionic_strength ** 0.5)) / ionic_strength
819
- # return coeff * unit('kg/mol')
659
+ # return coeff * ureg.Quantity('kg/mol')
820
660
 
821
661
 
822
662
  def _pitzer_B_phi(ionic_strength, alpha1, alpha2, beta0, beta1, beta2):
823
- """
824
- Return the B^\Phi coefficient for the Pitzer ion interaction model.
663
+ r"""
664
+ Returns the B^\Phi coefficient for the Pitzer ion interaction model.
825
665
 
826
- .. math:: B^\Phi = \\beta_0 + \\beta1 \exp(-\\alpha_1 I ^{0.5}) + \\beta_2 \exp(-\\alpha_2 I ^ {0.5})
666
+ This function calculates the B^\Phi coefficient using the formula:
827
667
 
828
- or
668
+ .. math:: B^\Phi = \beta_0 + \beta1 \exp(-\alpha_1 I ^{0.5}) + \beta_2 \exp(-\alpha_2 I ^ {0.5})
829
669
 
830
- .. math:: B^\\Phi = B^\\gamma - B_{MX}
670
+ or
831
671
 
832
- Parameters
833
- ----------
834
- ionic_strength: number
835
- The ionic strength of the parent solution, mol/kg
836
- alpha1, alpha2: number
837
- Coefficients for the Pitzer model, kg ** 0.5 / mol ** 0.5
838
- beta0, beta1, beta2: number
839
- Coefficients for the Pitzer model. These ion-interaction parameters are
840
- specific to each salt system.
672
+ .. math:: B^\Phi = B^\gamma - B_{MX}
841
673
 
842
- Returns
843
- -------
844
- float
845
- The B^Phi parameter for the Pitzer ion interaction model.
674
+ Args:
675
+ ionic_strength: The ionic strength of the parent solution, mol/kg.
676
+ alpha1, alpha2: Coefficients for the Pitzer model, kg ** 0.5 / mol ** 0.5.
677
+ beta0, beta1, beta2: Coefficients for the Pitzer model. These ion-interaction parameters are
678
+ specific to each salt system.
846
679
 
847
- References
848
- ----------
849
- Scharge, T., Munoz, A.G., and Moog, H.C. (2012). Activity Coefficients of Fission Products in Highly
850
- Salinary Solutions of Na+, K+, Mg2+, Ca2+, Cl-, and SO42- : Cs+.
851
- /Journal of Chemical& Engineering Data (57), p. 1637-1647.
680
+ Returns:
681
+ float: The B^Phi parameter for the Pitzer ion interaction model.
852
682
 
853
- Kim, H., & Jr, W. F. (1988). Evaluation of Pitzer ion interaction parameters of aqueous electrolytes at 25 degree C. 1. Single salt parameters.
854
- Journal of Chemical and Engineering Data, (2), 177–184.
683
+ References:
684
+ Scharge, T., Munoz, A.G., and Moog, H.C. (2012). Activity Coefficients of Fission Products in Highly
685
+ Salinary Solutions of Na+, K+, Mg2+, Ca2+, Cl-, and SO42- : Cs+.
686
+ /Journal of Chemical& Engineering Data (57), p. 1637-1647.
855
687
 
856
- Beyer, R., & Steiger, M. (2010). Vapor Pressure Measurements of NaHCOO + H 2 O and KHCOO + H 2 O from 278 to 308 K
857
- and Representation with an Ion Interaction (Pitzer) Model.
858
- Journal of Chemical & Engineering Data, 55(2), 830–838. doi:10.1021/je900487a
688
+ Kim, H., & Jr, W. F. (1988). Evaluation of Pitzer ion interaction parameters of aqueous electrolytes at 25 degree C. 1. Single salt parameters.
689
+ Journal of Chemical and Engineering Data, (2), 177-184.
859
690
 
691
+ Beyer, R., & Steiger, M. (2010). Vapor Pressure Measurements of NaHCOO + H 2 O and KHCOO + H 2 O from 278 to 308 K
692
+ and Representation with an Ion Interaction (Pitzer) Model.
693
+ Journal of Chemical & Engineering Data, 55(2), 830-838. doi:10.1021/je900487a
860
694
  """
861
- coeff = (
862
- beta0
863
- + beta1 * math.exp(-alpha1 * ionic_strength ** 0.5)
864
- + beta2 * math.exp(-alpha2 * ionic_strength ** 0.5)
865
- )
866
- return coeff
695
+ import math
696
+
697
+ # TODO - for some reason this specific method requires the use of math.exp rather than np.exp. Using np.exp raises
698
+ # a dimensionalityerror.
699
+ return beta0 + beta1 * math.exp(-alpha1 * ionic_strength**0.5) + beta2 * math.exp(-alpha2 * ionic_strength**0.5)
867
700
 
868
701
 
869
702
  # def _pitzer_C_MX(C_phi,z_cation,z_anion):
@@ -875,7 +708,7 @@ def _pitzer_B_phi(ionic_strength, alpha1, alpha2, beta0, beta1, beta2):
875
708
  # Parameters
876
709
  # ----------
877
710
  # C_phi: number
878
- # The C_phi paramter for the Pitzer ion interaction model.
711
+ # The C_phi parameter for the Pitzer ion interaction model.
879
712
  # z_cation, z_anion: int
880
713
  # The formal charge on the cation and anion, respectively
881
714
  #
@@ -888,15 +721,15 @@ def _pitzer_B_phi(ionic_strength, alpha1, alpha2, beta0, beta1, beta2):
888
721
  # ----------
889
722
  # Kim, H., & Jr, W. F. (1988).
890
723
  # Evaluation of Pitzer ion interaction parameters of aqueous electrolytes at 25 degree C. 1. Single salt parameters.
891
- # Journal of Chemical and Engineering Data, (2), 177184.
724
+ # Journal of Chemical and Engineering Data, (2), 177-184.
892
725
  #
893
726
  # May, P. M., Rowland, D., Hefter, G., & Königsberger, E. (2011).
894
727
  # A Generic and Updatable Pitzer Characterization of Aqueous Binary Electrolyte Solutions at 1 bar and 25 °C.
895
- # Journal of Chemical & Engineering Data, 56(12), 50665077. doi:10.1021/je2009329
728
+ # Journal of Chemical & Engineering Data, 56(12), 5066-5077. doi:10.1021/je2009329
896
729
  # '''
897
730
  #
898
731
  # coeff = C_phi / ( 2 * abs(z_cation * z_anion) ** 0.5 )
899
- # return coeff * unit('kg ** 2 /mol ** 2')
732
+ # return coeff * ureg.Quantity('kg ** 2 /mol ** 2')
900
733
 
901
734
 
902
735
  def _pitzer_log_gamma(
@@ -910,71 +743,45 @@ def _pitzer_log_gamma(
910
743
  nu_cation,
911
744
  nu_anion,
912
745
  temperature="25 degC",
913
- b=unit("1.2 kg**0.5/mol**0.5"),
746
+ b=ureg.Quantity(1.2, "kg**0.5/mol**0.5"),
914
747
  ):
915
- """
916
- Return the natural logarithm of the binary activity coefficient calculated by the Pitzer
748
+ r"""
749
+ Returns the natural logarithm of the binary activity coefficient calculated by the Pitzer
917
750
  ion interaction model.
918
751
 
919
- .. math:: \\ln \\gamma_{MX} = -{|z_+ z_-| A^{Phi} ( I ^ {0.5} \\over (1 + b I ^ {0.5})} + {2 \\over b }\\ln (1 + b I ^ {0.5}) )+\
920
- + {m (2 \\nu_+ \\nu_-) \\over (\\nu_+ + \\nu_-)} (B_{MX} + B_{MX}^\\Phi) + {m^2(3 (\\nu_+ \\nu_-)^{1.5} \\over (\\nu_+ + \\nu_-))} C_{MX}^\\Phi
921
-
922
-
923
- Parameters
924
- ----------
925
- ionic_strength: Quantity
926
- The ionic strength of the parent solution, mol/kg
927
- molality: Quantity
928
- The concentration of the salt, mol/kg
929
- B_MX,B_phi,C_phi: Quantity
930
- Calculated paramters for the Pitzer ion interaction model.
931
- z_cation, z_anion: int
932
- The formal charge on the cation and anion, respectively
933
- nu_cation, nu_anion: int
934
- The stoichiometric coefficient of the cation and anion in the salt
935
- temperature: str Quantity
936
- String representing the temperature of the solution. Defaults to '25 degC' if not specified.
937
- b: number, optional
938
- Coefficient. Usually set equal to 1.2 kg ** 0.5 / mol ** 0.5 and considered independent of temperature and pressure
939
-
940
- Returns
941
- -------
942
- float
943
- The natural logarithm of the binary activity coefficient calculated by the Pitzer ion interaction model.
944
-
945
- References
946
- ----------
947
- Kim, H., & Jr, W. F. (1988).
948
- Evaluation of Pitzer ion interaction parameters of aqueous electrolytes at 25 degree C. 1. Single salt parameters.
949
- Journal of Chemical and Engineering Data, (2), 177–184.
950
-
951
- May, P. M., Rowland, D., Hefter, G., & Königsberger, E. (2011).
952
- A Generic and Updatable Pitzer Characterization of Aqueous Binary Electrolyte Solutions at 1 bar and 25 °C.
953
- Journal of Chemical & Engineering Data, 56(12), 5066–5077. doi:10.1021/je2009329
752
+ .. math::
753
+
754
+ \ln \gamma_{MX} = -|z_+ z_-| A^{Phi} ( \frac{I ^ {0.5}}{(1 + b I ^ {0.5})} + \frac{2}{b} \ln{(1 + b I ^ {0.5})} )+ \frac{m (2 \nu_+ \nu_-)}{(\nu_+ + \nu_-)} (B_{MX} + B_{MX}^\Phi) + \frac{m^2(3 (\nu_+ \nu_-)^{1.5}}{(\nu_+ + \nu_-))} C_{MX}^\Phi
755
+
756
+ Args:
757
+ ionic_strength (Quantity): The ionic strength of the parent solution, mol/kg.
758
+ molality (Quantity): The concentration of the salt, mol/kg.
759
+ B_MX, B_phi, C_phi (Quantity): Calculated parameters for the Pitzer ion interaction model.
760
+ z_cation, z_anion (int): The formal charge on the cation and anion, respectively.
761
+ nu_cation, nu_anion (int): The stoichiometric coefficient of the cation and anion in the salt.
762
+ temperature (str, Quantity): String representing the temperature of the solution. Defaults to '25 degC' if not specified.
763
+ b (number, optional): Coefficient. Usually set equal to 1.2 kg ** 0.5 / mol ** 0.5 and considered independent of temperature and pressure.
764
+
765
+ Returns:
766
+ float: The natural logarithm of the binary activity coefficient calculated by the Pitzer ion interaction model.
767
+
768
+ References:
769
+ Kim, H., & Jr, W. F. (1988). Evaluation of Pitzer ion interaction parameters of aqueous electrolytes at 25 degree C. 1. Single salt parameters.
770
+ Journal of Chemical and Engineering Data, (2), 177-184.
771
+
772
+ May, P. M., Rowland, D., Hefter, G., & Königsberger, E. (2011). A Generic and Updatable Pitzer Characterization of Aqueous Binary Electrolyte Solutions at 1 bar and 25 °C.
773
+ Journal of Chemical & Engineering Data, 56(12), 5066-5077. doi:10.1021/je2009329
954
774
  """
955
775
  first_term = (
956
776
  -1
957
777
  * abs(z_cation * z_anion)
958
778
  * _debye_parameter_osmotic(temperature)
959
- * (
960
- ionic_strength ** 0.5 / (1 + b * ionic_strength ** 0.5)
961
- + 2 / b * math.log(1 + b * ionic_strength ** 0.5)
962
- )
779
+ * (ionic_strength**0.5 / (1 + b * ionic_strength**0.5) + 2 / b * np.log(1 + b * ionic_strength**0.5))
963
780
  )
964
- second_term = (
965
- 2 * molality * nu_cation * nu_anion / (nu_cation + nu_anion) * (B_MX + B_phi)
966
- )
967
- third_term = (
968
- 3
969
- * molality ** 2
970
- * (nu_cation * nu_anion) ** 1.5
971
- / (nu_cation + nu_anion)
972
- * C_phi
973
- )
974
-
975
- ln_gamma = first_term + second_term + third_term
781
+ second_term = 2 * molality * nu_cation * nu_anion / (nu_cation + nu_anion) * (B_MX + B_phi)
782
+ third_term = 3 * molality**2 * (nu_cation * nu_anion) ** 1.5 / (nu_cation + nu_anion) * C_phi
976
783
 
977
- return ln_gamma
784
+ return first_term + second_term + third_term
978
785
 
979
786
 
980
787
  def get_osmotic_coefficient_pitzer(
@@ -993,113 +800,80 @@ def get_osmotic_coefficient_pitzer(
993
800
  temperature="25 degC",
994
801
  b=1.2,
995
802
  ):
996
- """Return the osmotic coefficient of water in an electrolyte solution according to the Pitzer model.
997
-
998
- Parameters
999
- ----------
1000
- ionic_strength: Quantity
1001
- The ionic strength of the parent solution, mol/kg
1002
- molality: Quantity
1003
- The molal concentration of the parent salt, mol/kg
1004
- alpha1, alpha2: number
1005
- Coefficients for the Pitzer model. This function assigns the coefficients
1006
- proper units of kg ** 0.5 / mol ** 0.5 after they are entered.
1007
- beta0, beta1, beta2, C_phi
1008
- Coefficients for the Pitzer model. These ion-interaction parameters are
1009
- specific to each salt system.
1010
- z_cation, z_anion: int
1011
- The formal charge on the cation and anion, respectively
1012
- nu_cation, nu_anion: int
1013
- The stoichiometric coefficient of the cation and anion in the salt
1014
- temperature: str Quantity
1015
- String representing the temperature of the solution. Defaults to '25 degC' if not specified.
1016
- b: number, optional
1017
- Coefficient. Usually set equal to 1.2 and
1018
- considered independent of temperature and pressure. If provided, this
1019
- coefficient is assigned proper units of kg ** 0.5 / mol ** 0.5 after
1020
- entry.
1021
-
1022
- Returns
1023
- -------
1024
- Quantity
1025
- The osmotic coefficient of water, dimensionless
1026
-
1027
- Examples
1028
- --------
1029
- Experimental value according to Beyer and Stieger reference is 1.3550
1030
-
1031
- >>> get_osmotic_coefficient_pitzer(10.175*unit('mol/kg'),10.175*unit('mol/kg'),1,0.5,-.0181191983,-.4625822071,.4682,.000246063,1,-1,1,1,b=1.2)
1032
- 1.3552 ...
1033
-
1034
- Experimental value according to Beyer and Stieger reference is 1.084
1035
-
1036
- >>> get_osmotic_coefficient_pitzer(5.6153*unit('mol/kg'),5.6153*unit('mol/kg'),3,0.5,0.0369993,0.354664,0.0997513,-0.00171868,1,-1,1,1,b=1.2)
1037
- 1.0850 ...
1038
-
1039
- NOTE: the examples below are for comparison with experimental and modeling data presented in
1040
- the May et al reference below.
1041
-
1042
- 10 mol/kg ammonium nitrate. Estimated result (from graph) = 0.62
1043
-
1044
- >>> get_osmotic_coefficient_pitzer(10*unit('mol/kg'),10*unit('mol/kg'),2,0,-0.01709,0.09198,0,0.000419,1,-1,1,1,b=1.2)
1045
- 0.6143 ...
1046
-
1047
- 5 mol/kg ammonium nitrate. Estimated result (from graph) = 0.7
1048
-
1049
- >>> get_osmotic_coefficient_pitzer(5*unit('mol/kg'),5*unit('mol/kg'),2,0,-0.01709,0.09198,0,0.000419,1,-1,1,1,b=1.2)
1050
- 0.6925 ...
1051
-
1052
- 18 mol/kg ammonium nitrate. Estimated result (from graph) = 0.555
1053
-
1054
- >>> get_osmotic_coefficient_pitzer(18*unit('mol/kg'),18*unit('mol/kg'),2,0,-0.01709,0.09198,0,0.000419,1,-1,1,1,b=1.2)
1055
- 0.5556 ...
1056
-
1057
- References
1058
- ----------
1059
- Scharge, T., Munoz, A.G., and Moog, H.C. (2012). Activity Coefficients of Fission Products in Highly
1060
- Salinary Solutions of Na+, K+, Mg2+, Ca2+, Cl-, and SO42- : Cs+.
1061
- /Journal of Chemical& Engineering Data (57), p. 1637-1647.
1062
-
1063
- Kim, H., & Jr, W. F. (1988). Evaluation of Pitzer ion interaction parameters of aqueous electrolytes at 25 degree C. 1. Single salt parameters.
1064
- Journal of Chemical and Engineering Data, (2), 177–184.
1065
-
1066
- May, P. M., Rowland, D., Hefter, G., & Königsberger, E. (2011).
1067
- A Generic and Updatable Pitzer Characterization of Aqueous Binary Electrolyte Solutions at 1 bar and 25 °C.
1068
- Journal of Chemical & Engineering Data, 56(12), 5066–5077. doi:10.1021/je2009329
1069
-
1070
- Beyer, R., & Steiger, M. (2010). Vapor Pressure Measurements of NaHCOO + H 2 O and KHCOO + H 2 O from 278 to 308 K
1071
- and Representation with an Ion Interaction (Pitzer) Model.
1072
- Journal of Chemical & Engineering Data, 55(2), 830–838. doi:10.1021/je900487a
1073
-
1074
- See Also
1075
- --------
1076
- _debye_parameter_activity
1077
- _pitzer_B_MX
1078
- _pitzer_B_gamma
1079
- _pitzer_B_phi
1080
- _pitzer_log_gamma
803
+ """
804
+ Return the osmotic coefficient of water in an electrolyte solution according to the Pitzer model.
805
+
806
+ Args:
807
+ ionic_strength (Quantity): The ionic strength of the parent solution, mol/kg.
808
+ molality (Quantity): The molal concentration of the parent salt, mol/kg.
809
+ alpha1, alpha2 (number): Coefficients for the Pitzer model. This function assigns the coefficients proper units of kg ** 0.5 / mol ** 0.5 after they are entered.
810
+ beta0, beta1, beta2, C_phi: Coefficients for the Pitzer model. These ion-interaction parameters are specific to each salt system.
811
+ z_cation, z_anion (int): The formal charge on the cation and anion, respectively.
812
+ nu_cation, nu_anion (int): The stoichiometric coefficient of the cation and anion in the salt.
813
+ temperature (str, Quantity): String representing the temperature of the solution. Defaults to '25 degC' if not specified.
814
+ b (number, optional): Coefficient. Usually set equal to 1.2 and considered independent of temperature and pressure. If provided, this coefficient is assigned proper units of kg ** 0.5 / mol ** 0.5 after entry.
815
+
816
+ Returns:
817
+ Quantity: The osmotic coefficient of water, dimensionless.
818
+
819
+ Examples:
820
+ Experimental value according to Beyer and Stieger reference is 1.3550
821
+
822
+ >>> get_osmotic_coefficient_pitzer(10.175*ureg.Quantity('mol/kg'),10.175*ureg.Quantity('mol/kg'),1,0.5,-.0181191983,-.4625822071,.4682,.000246063,1,-1,1,1,b=1.2)
823
+ 1.3552 ...
824
+
825
+ Experimental value according to Beyer and Stieger reference is 1.084
826
+
827
+ >>> get_osmotic_coefficient_pitzer(5.6153*ureg.Quantity('mol/kg'),5.6153*ureg.Quantity('mol/kg'),3,0.5,0.0369993,0.354664,0.0997513,-0.00171868,1,-1,1,1,b=1.2)
828
+ 1.0850 ...
829
+
830
+ Notes: the examples below are for comparison with experimental and modeling data presented in the May et al reference below.
831
+
832
+ 10 mol/kg ammonium nitrate. Estimated result (from graph) = 0.62
833
+
834
+ >>> get_osmotic_coefficient_pitzer(10*ureg.Quantity('mol/kg'),10*ureg.Quantity('mol/kg'),2,0,-0.01709,0.09198,0,0.000419,1,-1,1,1,b=1.2)
835
+ 0.6143 ...
1081
836
 
837
+ 5 mol/kg ammonium nitrate. Estimated result (from graph) = 0.7
1082
838
 
839
+ >>> get_osmotic_coefficient_pitzer(5*ureg.Quantity('mol/kg'),5*ureg.Quantity('mol/kg'),2,0,-0.01709,0.09198,0,0.000419,1,-1,1,1,b=1.2)
840
+ 0.6925 ...
841
+
842
+ 18 mol/kg ammonium nitrate. Estimated result (from graph) = 0.555
843
+
844
+ >>> get_osmotic_coefficient_pitzer(18*ureg.Quantity('mol/kg'),18*ureg.Quantity('mol/kg'),2,0,-0.01709,0.09198,0,0.000419,1,-1,1,1,b=1.2)
845
+ 0.5556 ...
846
+
847
+ References:
848
+ Scharge, T., Munoz, A.G., and Moog, H.C. (2012). Activity Coefficients of Fission Products in Highly Salinary Solutions of Na+, K+, Mg2+, Ca2+, Cl-, and SO42- : Cs+.
849
+ /Journal of Chemical& Engineering Data (57), p. 1637-1647.
850
+
851
+ Kim, H., & Jr, W. F. (1988). Evaluation of Pitzer ion interaction parameters of aqueous electrolytes at 25 degree C. 1. Single salt parameters.
852
+ Journal of Chemical and Engineering Data, (2), 177-184.
853
+
854
+ May, P. M., Rowland, D., Hefter, G., & Königsberger, E. (2011). A Generic and Updatable Pitzer Characterization of Aqueous Binary Electrolyte Solutions at 1 bar and 25 °C.
855
+ Journal of Chemical & Engineering Data, 56(12), 5066-5077. doi:10.1021/je2009329
856
+
857
+ Beyer, R., & Steiger, M. (2010). Vapor Pressure Measurements of NaHCOO + H 2 O and KHCOO + H 2 O from 278 to 308 K and Representation with an Ion Interaction (Pitzer) Model.
858
+ Journal of Chemical & Engineering Data, 55(2), 830-838. doi:10.1021/je900487a
859
+
860
+ See Also:
861
+ :func:`_debye_parameter_activity`
862
+ :func:`_pitzer_B_MX`
863
+ :func:`_pitzer_B_phi`
864
+ :func:`_pitzer_log_gamma`
1083
865
  """
1084
866
  # assign proper units to alpha1, alpha2, and b
1085
- alpha1 = alpha1 * unit("kg ** 0.5 / mol ** 0.5")
1086
- alpha2 = alpha2 * unit("kg ** 0.5 / mol ** 0.5")
1087
- b = b * unit("kg ** 0.5 / mol ** 0.5")
1088
- C_phi = C_phi * unit("kg ** 2 /mol ** 2")
1089
- B_phi = _pitzer_B_phi(ionic_strength, alpha1, alpha2, beta0, beta1, beta2) * unit(
1090
- "kg/mol"
867
+ alpha1 = ureg.Quantity(alpha1, "kg ** 0.5 / mol ** 0.5")
868
+ alpha2 = ureg.Quantity(alpha2, "kg ** 0.5 / mol ** 0.5")
869
+ b = ureg.Quantity(b, "kg ** 0.5 / mol ** 0.5")
870
+ C_phi = ureg.Quantity(C_phi, "kg ** 2 /mol ** 2")
871
+ B_phi = ureg.Quantity(_pitzer_B_phi(ionic_strength, alpha1, alpha2, beta0, beta1, beta2), "kg/mol")
872
+
873
+ first_term = 1 - _debye_parameter_osmotic(temperature) * abs(z_cation * z_anion) * ionic_strength**0.5 / (
874
+ 1 + b * ionic_strength**0.5
1091
875
  )
1092
-
1093
- first_term = 1 - _debye_parameter_osmotic(temperature) * abs(
1094
- z_cation * z_anion
1095
- ) * ionic_strength ** 0.5 / (1 + b * ionic_strength ** 0.5)
1096
876
  second_term = molality * 2 * nu_cation * nu_anion / (nu_cation + nu_anion) * B_phi
1097
- third_term = (
1098
- molality ** 2
1099
- * (2 * (nu_cation * nu_anion) ** 1.5 / (nu_cation + nu_anion))
1100
- * C_phi
1101
- )
1102
-
1103
- osmotic_coefficient = first_term + second_term + third_term
877
+ third_term = molality**2 * (2 * (nu_cation * nu_anion) ** 1.5 / (nu_cation + nu_anion)) * C_phi
1104
878
 
1105
- return osmotic_coefficient
879
+ return first_term + second_term + third_term