Skip to content

Commit 1fc74cb

Browse files
authored
Merge pull request #78 from KingsburyLab/D_temp
D temp
2 parents 7906edb + 331ec43 commit 1fc74cb

10 files changed

+5222
-2473
lines changed

CHANGELOG.md

+19-1
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,42 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [0.10.0] - 2023-11-10
8+
## [0.10.0] - 2023-11-12
99

1010
### Added
1111

12+
- `Solution`: Revamped docstrings for `conductivity`, `get_transport_number`, `get_molar_conductivity`, and
13+
`get_diffusion_coefficient`.
14+
- `Solution`: new method `get_diffusion_coefficient` for dedicated retrieval of diffusion coefficients. This method
15+
implements an improved algorithm for temperature adjustment and a new algorithm for adjusting infinite dilution D values
16+
for ionic strengthe effects. The algorithm is identical to that implemented in PHREEQC >= 3.4.
17+
- Database: empirical parameters for temperature and ionic strength adjustment of diffusion coefficients for 15 solutes
18+
- Added tests for temperature and ionic strength adjustment and conductivity
1219
- Docs: new tutorial notebooks
1320
- Docs: remove duplicate contributing pages (Closes [#68](https://github.com/KingsburyLab/pyEQL/issues/68))
1421
- `Solution`: new method `to_file()` for more convenient saving Solution object to json or yaml files. (@kirill-push)
1522
- `Solution`: new method `from_file()` for more convenient loading Solution object from json or yaml files. (@kirill-push)
1623
- `Solution`: new classmethod `from_preset()` to `replace pyEQL.functions.autogenerate()` and instantiate a solution from a preset composition. (@kirill-push)
1724

25+
### Changed
26+
27+
- `Solution`: method af adjusting diffusion coefficients for temperature was updated (same as used in PHREEQC >= 3.4)
28+
- `Solution.conductvity`: improved equation (same as used in PHREEQC >= 3.4) which is more accurate at higher concentrations
29+
1830
### Fixed
1931

32+
- Database errors with `Cs[+1]` diffusion coefficient and `KBr` Pitzer parameters
2033
- Restored filter that suppresses duplicate log messages
2134

2235
### Deprecated
2336

2437
- `replace pyEQL.functions.autogenerate()` is now deprecated. Use `from_preset` instead.
2538

39+
### Removed
40+
41+
- The `activity_correction` kwarg in `get_transport_number` has been removed, because this now occurs by default and is
42+
handled in `get_diffusion_coefficient`.
43+
2644
## [0.9.2] - 2023-11-07
2745

2846
### Fixed

src/pyEQL/activity_correction.py

+48-56
Original file line numberDiff line numberDiff line change
@@ -15,106 +15,98 @@
1515
import math
1616

1717
from iapws import IAPWS95
18+
from pint import Quantity
1819

19-
# the pint unit registry
2020
from pyEQL import ureg
2121
from pyEQL.logging_system import logger
2222

2323

24-
def _debye_parameter_B(temperature="25 degC"):
24+
def _debye_parameter_B(temperature: str = "25 degC") -> Quantity:
2525
"""
2626
Return the constant B used in the extended Debye-Huckel equation.
2727
28-
Parameters
29-
----------
30-
temperature : str Quantity, optional
31-
String representing the temperature of the solution. Defaults to '25 degC' if not specified.
28+
Args:
29+
temperature: The temperature of the solution at which to calculate the constant.
30+
Defaults to '25 degC'.
3231
33-
Notes
34-
-----
35-
The parameter B is equal to:
32+
Returns:
33+
The parameter B for use in extended Debye-Huckel equation (base e). For base 10,
34+
divide the resulting value by 2.303. Note that A is often given in base 10 terms
35+
in older textbooks and reference material (0.3281 at 25 degC).
3636
37-
.. math:: B = ( {8 \\pi N_A e^2 \\over 1000 \\epsilon k T} ) ^ {1 \\over 2}
37+
Notes:
38+
The parameter B is equal to:
3839
39-
References
40-
----------
41-
Bockris and Reddy. /Modern Electrochemistry/, vol 1. Plenum/Rosetta, 1977, p.210.
40+
.. math:: B = ( \\frac{{2 N_A \\rho_w e^2}{\\epsilon_o \\epsilon_r k T}) ^ {1 \\over 2}
4241
43-
Examples:
44-
--------
45-
>>> _debye_parameter_B() #doctest: +ELLIPSIS
46-
0.3291...
42+
References:
43+
Bockris and Reddy. /Modern Electrochemistry/, vol 1. Plenum/Rosetta, 1977, p.210.
44+
45+
Archer, Donald G. and Wang, Peiming. "The Dielectric Constant of Water \
46+
and Debye-Huckel Limiting Law Slopes." /J. Phys. Chem. Ref. Data/ 19(2), 1990.
4747
48+
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
49+
50+
https://en.wikipedia.org/wiki/Debye%E2%80%93H%C3%BCckel_equation
4851
"""
4952
water_substance = IAPWS95(
50-
T=ureg.Quantity(temperature).magnitude,
53+
T=ureg.Quantity(temperature).to("K").magnitude,
5154
P=ureg.Quantity("1 atm").to("MPa").magnitude,
5255
)
5356

5457
param_B = (
55-
8
56-
* math.pi
58+
2
5759
* ureg.N_A
60+
* ureg.Quantity(water_substance.rho, "g/L")
5861
* ureg.elementary_charge**2
59-
/ (
60-
water_substance.mu
61-
* ureg.Quantity("1 g/L") # in g/L
62-
* ureg.epsilon_0
63-
* water_substance.epsilon
64-
* ureg.boltzmann_constant
65-
* ureg.Quantity(temperature)
66-
)
62+
/ (ureg.epsilon_0 * water_substance.epsilon * ureg.boltzmann_constant * ureg.Quantity(temperature))
6763
) ** 0.5
6864
return param_B.to_base_units()
6965

7066

71-
def _debye_parameter_activity(temperature="25 degC"):
67+
def _debye_parameter_activity(temperature: str = "25 degC") -> "Quantity":
7268
"""
73-
Return the constant A for use in the Debye-Huckel limiting law (base 10).
69+
Return the constant A for use in the Debye-Huckel limiting law (base e).
7470
75-
Parameters
76-
----------
77-
temperature : str Quantity, optional
78-
String representing the temperature of the solution. Defaults to '25 degC' if not specified.
71+
Args:
72+
temperature: The temperature of the solution at which to calculate the constant.
73+
Defaults to '25 degC'.
7974
80-
Returns
81-
-------
82-
Quantity The parameter A for use in the Debye-Huckel limiting law (base e)
75+
Returns:
76+
The parameter A for use in the Debye-Huckel limiting law (base e). For base 10,
77+
divide the resulting value by 2.303. Note that A is often given in base 10 terms
78+
in older textbooks and reference material (0.509 at 25 degC).
8379
84-
Notes
85-
-----
86-
The parameter A is equal to:
80+
Notes:
81+
The parameter A is equal to:
8782
88-
.. math::
89-
A^{\\gamma} = {e^3 ( 2 \\pi N_A {\\rho})^{0.5} \\over (4 \\pi \\epsilon_o \\epsilon_r k T)^{1.5}}
83+
.. math::
84+
A^{\\gamma} = {e^3 ( 2 \\pi N_A {\\rho})^{0.5} \\over (4 \\pi \\epsilon_o \\epsilon_r k T)^{1.5}}
9085
91-
Note that this equation returns the parameter value that can be used to calculate
92-
the natural logarithm of the activity coefficient. For base 10, divide the
93-
value returned by 2.303. The value is often given in base 10 terms (0.509 at
94-
25 degC) in older textbooks.
86+
Note that this equation returns the parameter value that can be used to calculate
87+
the natural logarithm of the activity coefficient. For base 10, divide the
88+
value returned by 2.303.
9589
96-
References
97-
----------
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.
90+
References:
91+
Archer, Donald G. and Wang, Peiming. "The Dielectric Constant of Water \
92+
and Debye-Huckel Limiting Law Slopes." /J. Phys. Chem. Ref. Data/ 19(2), 1990.
10093
101-
Examples:
102-
--------
103-
>>> _debye_parameter_activity() #doctest: +ELLIPSIS
104-
1.17499...
94+
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
95+
96+
https://en.wikipedia.org/wiki/Debye%E2%80%93H%C3%BCckel_equation
10597
10698
See Also:
10799
:py:func:`_debye_parameter_osmotic`
108100
109101
"""
110102
water_substance = IAPWS95(
111-
T=ureg.Quantity(temperature).magnitude,
103+
T=ureg.Quantity(temperature).to("K").magnitude,
112104
P=ureg.Quantity("1 atm").to("MPa").magnitude,
113105
)
114106

115107
debyeparam = (
116108
ureg.elementary_charge**3
117-
* (2 * math.pi * ureg.N_A * water_substance.rho * ureg.Quantity("1 g/L")) ** 0.5
109+
* (2 * math.pi * ureg.N_A * ureg.Quantity(water_substance.rho, "g/L")) ** 0.5
118110
/ (
119111
4
120112
* math.pi

0 commit comments

Comments
 (0)