pyEQL 0.5.2__py3-none-any.whl → 1.0.3__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 +211 -0
  21. pyEQL-1.0.3.dist-info/AUTHORS.md +13 -0
  22. {pyEQL-0.5.2.dist-info → pyEQL-1.0.3.dist-info}/COPYING +1 -1
  23. pyEQL-0.5.2.dist-info/LICENSE → pyEQL-1.0.3.dist-info/LICENSE.txt +3 -7
  24. pyEQL-1.0.3.dist-info/METADATA +131 -0
  25. pyEQL-1.0.3.dist-info/RECORD +27 -0
  26. {pyEQL-0.5.2.dist-info → pyEQL-1.0.3.dist-info}/WHEEL +1 -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.0.3.dist-info}/top_level.txt +0 -0
pyEQL/__init__.py CHANGED
@@ -1,49 +1,56 @@
1
1
  """
2
- pyEQL
3
- =====
4
-
5
2
  pyEQL is a python package for calculating the properties of aqueous solutions
6
3
  and performing chemical thermodynamics computations.
7
4
 
8
- :copyright: 2013-2020 by Ryan S. Kingsbury
5
+ :copyright: 2013-2024 by Ryan S. Kingsbury
9
6
  :license: LGPL, see LICENSE for more details.
10
-
11
7
  """
12
- # initialize the parameters database
13
- from pyEQL.database import Paramsdb
14
-
15
- paramsDB = Paramsdb()
16
-
17
- from pyEQL.parameter import unit
18
- from pyEQL.functions import *
19
- from pyEQL.solution import Solution
20
-
21
- # define custom assertion functions to compare model output with experimental
22
- # data when running units tests.
23
- # See https://stackoverflow.com/questions/6655724/how-to-write-a-custom-assertfoo-method-in-python
24
- # for the method I'm using here.
25
-
26
-
27
- class CustomAssertions:
28
- def assertWithinExperimentalError(self, result, expected, tol=0.05):
29
- """
30
- Test whether 'result' is within 'tol' relative error of
31
- 'expected'
32
- """
33
- rel_error = abs(result - expected) / expected
34
- if not rel_error < tol:
35
- raise AssertionError(
36
- "Result {:} differs from expected value by {:.2f}%".format(
37
- result, rel_error * 100
38
- )
39
- )
40
-
41
-
42
- # enable easy testing
43
- def test():
44
- """Run all tests.
45
- :return: a :class:`unittest.TestResult` object
46
- """
47
- from .tests import run
48
-
49
- return run()
8
+
9
+ import logging
10
+ from importlib.metadata import PackageNotFoundError, version # pragma: no cover
11
+ from importlib.resources import files
12
+
13
+ from maggma.stores import JSONStore
14
+ from pint import UnitRegistry
15
+
16
+ try:
17
+ # Change here if project is renamed and does not equal the package name
18
+ dist_name = __name__
19
+ __version__ = version(dist_name)
20
+ except PackageNotFoundError: # pragma: no cover
21
+ __version__ = "unknown"
22
+ finally:
23
+ del version, PackageNotFoundError
24
+
25
+ # logging
26
+ logger = logging.getLogger("pyEQL")
27
+ logger.setLevel(logging.WARNING)
28
+ logger.addHandler(logging.NullHandler())
29
+
30
+
31
+ # Units handling
32
+ # per the pint documentation, it's important that pint and its associated Unit
33
+ # Registry are only instantiated once.
34
+ # here we assign the identifier 'unit' to the UnitRegistry
35
+ # the cache_folder arg is added to speed up registry instantiation
36
+ ureg = UnitRegistry(cache_folder=":auto:")
37
+ # convert "offset units" so that, e.g. Quantity('25 degC') works without error
38
+ # see https://pint.readthedocs.io/en/0.22/user/nonmult.html?highlight=offset#temperature-conversion
39
+ ureg.autoconvert_offset_to_baseunit = True
40
+ # append custom unit definitions and contexts
41
+ fname = files("pyEQL") / "pint_custom_units.txt"
42
+ ureg.load_definitions(fname)
43
+ # activate the "chemistry" context globally
44
+ ureg.enable_contexts("chem")
45
+ # set the default string formatting for pint quantities
46
+ ureg.default_format = "P~"
47
+
48
+ # create a Store for the default database
49
+ json_db_file = files("pyEQL") / "database" / "pyeql_db.json"
50
+ IonDB = JSONStore(str(json_db_file), key="formula", encoding="utf8")
51
+ # By calling connect on init, we get the expensive JSON reading operation out
52
+ # of the way. Subsequent calls to connect will bypass this and access the already-
53
+ # instantiated Store in memory, which should speed up instantiation of Solution objects.
54
+ IonDB.connect()
55
+
56
+ from pyEQL.solution import Solution # noqa: E402