Skip to content

Commit 9ff1ed6

Browse files
committed
Update docs, theme, CHANGELOG, switch to Markdown
Docs: change theme; add python badge WIP docs update 2
1 parent 00ed21f commit 9ff1ed6

35 files changed

+1625
-1225
lines changed

.readthedocs.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
# Required
55
version: 2
66

7+
# Set the OS, Python version and other tools you might need
8+
build:
9+
os: ubuntu-22.04
10+
tools:
11+
python: "3.10"
12+
713
# Build documentation in the docs/ directory with Sphinx
814
sphinx:
915
configuration: docs/conf.py
@@ -17,6 +23,5 @@ formats:
1723
- pdf
1824

1925
python:
20-
version: 3.8
2126
install:
2227
- requirements: docs/requirements.txt

CHANGELOG.md

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,53 @@
11
# pyEQL Changelog
22

3-
## 0.6.0 (in progress)
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
### Added
411

5-
- **BREAKING CHANGE** `Solute`: methods `get_formal_charge()`, `get_name()`, and `get_molecular_weight()` have been
6-
replaced by direct access to the attributes `charge`, `formula`, and `mw`, respectively.
7-
- **DEPRECATION NOTICE** `Solution`: new properties `pressure`, `temperature`, `pE`,
8-
- `pH`, `mass`, `density`, `viscosity_dynamic`, `viscosity_kinematic`, `ionic_strength`,
9-
- `conductivity`, `debye_length`, `bjerrum_length`, `alkalinity`, `hardness`,
10-
- `dielectric_constant`, `charge_balance` have replaced the corresponding get_XXX and
11-
set_XXX (for temperature and pressure) methods, which will be removed in a future
12-
release. `get_viscosity_relative` will be removed entirely.
1312
- `Solution`: add support for passing solutes as a `dict`
1413
- Implement extensible system for connecting `Solution` to various activity and speciation
1514
models. Models can be integrated into pyEQL by implementing an `EOS` class. The desired
1615
activity model is selected on init. Currently available models are `native` (for pyEQL's
1716
implementation of Pitzer, which decays gracefully into Debye-Huckel and other models if
1817
parameters are not available) or `ideal` for a dummy engine that returns unit activity
1918
coefficients. Support for additional external engines such as [`phreeqpython`](https://github.com/Vitens/phreeqpython) is planned.
20-
- **BREAKING CHANGE** disable 'verbose' kwarg in `get_activity` and `get_activity_coefficient`
19+
- Add `pymatgen`, `monty`, and `maggma` as dependencies
20+
- Add pre-commit configuration and lint with `ruff`
2121
- Add more comprehensive platform testing via `tox`
22+
23+
### Changed
24+
2225
- Replace `water_properties.py` with [iapws](https://github.com/jjgomera/iapws) package
23-
- Replace elements.py with `pymatgen.core.periodic_table`
24-
- Add `pymatgen` as a dependency
26+
- Replace `elements.py`` with `pymatgen.core.periodic_table`
2527
- Migrate all tests to `pytest`
26-
- Add pre-commit configuration and lint with `black`
27-
- Update packaging to use [pyscaffold](https://pyscaffold.org/en/stable/index.html)
28+
- Update packaging format to use [pyscaffold](https://pyscaffold.org/en/stable/index.html)
29+
30+
### Deprecated
31+
32+
- `Solution`: new properties `pressure`, `temperature`, `pE`, `pH`, `mass`, `density`, `viscosity_dynamic`, `viscosity_kinematic`, `ionic_strength`, `conductivity`, `debye_length`, `bjerrum_length`, `alkalinity`, `hardness`, `dielectric_constant`, `charge_balance` have replaced the corresponding get_XXX and set_XXX (for temperature and pressure) methods, which will be removed in a future release. `get_viscosity_relative` will be removed entirely.
33+
- `Solute`: methods `get_formal_charge()`, `get_name()`, and `get_molecular_weight()` have been
34+
replaced by direct access to the attributes `charge`, `formula`, and `mw`, respectively.
35+
36+
### Removed
37+
38+
- disable 'verbose' kwarg in `get_activity` and `get_activity_coefficient`
39+
40+
### Fixed
41+
42+
- Fixed various documentation rendering issues
2843

29-
## 0.5.2 (2020-04-21)
44+
## [0.5.2] - 2020-04-21
3045

3146
- Fix breaking bug introduced by upstream pint change to avogadro_number
3247
- Format project with black
3348
- Misc. linting and docstring changes
3449

35-
## 0.5.0 (2018-09-19)
50+
## [0.5.0] 2018-09-19
3651

3752
- Implement the effective Pitzer model for improved activity calculations in multicomponent solutions
3853
- Add support for calculation of activity and osmotic coefficients on different scales
@@ -46,7 +61,7 @@
4661
- DEPRECATED get_mole_fraction. Use get_amount() instead
4762
- Fix bug causing get_activity_coefficient to fail if the solute concentration was zero
4863

49-
## 0.4.0 (2016-07-14)
64+
## [0.4.0] 2016-07-14
5065

5166
- Add ability to calculate dielectric constant based on solution composition for salts
5267
- Add database entries for the viscosity 'B' parameter for 63 more inorganic ions
@@ -59,12 +74,12 @@
5974
- Fix bug causing ValueError exceptions when a solute has zero concentration
6075
- Numerous fixes and corrections in the documentation
6176

62-
## 0.3.1 (2016-02-24)
77+
## [0.3.1] 2016-02-24
6378

6479
- Fix packaging problems preventing installation from PyPi
6580
- Fix character encoding issue in Erying_viscosity database file
6681

67-
## 0.3.0 (2016-01-15)
82+
## [0.3.0] 2016-01-15
6883

6984
- Add method to calculate the total concentration of an element in a solution
7085
- Add method to automatically generate certain solutions (like seawater)
@@ -81,11 +96,11 @@
8196
- Fix bug related to retrieval of water properties
8297
- Documentation enhancements and fixes
8398

84-
## 0.2.2 (2015-08-28)
99+
## [0.2.2] 2015-08-28
85100

86101
- Fix bug in get_amount() causing no output when mass-based units were specified.
87102

88-
## 0.2.1 (2015-05-06)
103+
## [0.2.1] 2015-05-06
89104

90105
- Add 93 entries to diffusion coefficient database
91106
- Add 93 entries to Pitzer partial molar volume parameters database
@@ -95,6 +110,6 @@
95110
- Uploaded to the Python Package Index for easier installation
96111
- Add this changelog
97112

98-
## 0.2.0 (2015-03-26)
113+
## [0.2.0] 2015-03-26
99114

100115
- First public release

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
[![testing](https://github.com/rkingsbury/pyeql/workflows/testing/badge.svg)](https://github.com/rkingsbury/pyeql/actions?query=workflow%3Atesting) [![codecov](https://codecov.io/gh/rkingsbury/pyeql/branch/main/graph/badge.svg?token=I7RP0QML6S)](https://codecov.io/gh/rkingsbury/pyeql)
1+
[![testing](https://github.com/rkingsbury/pyeql/workflows/testing/badge.svg)](https://github.com/rkingsbury/pyeql/actions?query=workflow%3Atesting)
2+
[![codecov](https://codecov.io/gh/rkingsbury/pyeql/branch/main/graph/badge.svg?token=I7RP0QML6S)](https://codecov.io/gh/rkingsbury/pyeql)
3+
![Supported python versions](https://img.shields.io/badge/python-3.8%20%7C%203.9%20%7C%203.10%20%7C%203.11-blue)
24

35
# pyEQL
46

docs/chemistry.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
(chemistry)=
2+
3+
# Chemical Formulas
4+
5+
pyEQL interprets the chemical formula of a substance to calculate its molecular
6+
weight and formal charge. The formula is also used as a key to search the
7+
database for parameters (e.g. diffusion coefficient) that are used in subsequent
8+
calculations.
9+
10+
## How to Enter Valid Chemical Formulas
11+
12+
Generally speaking, type the chemical formula of your solute the "normal" way
13+
and `pyEQL` should be able to inerpret it. Internally, `pyEQL` uses the [`pymatgen.core.ion.Ion`](https://pymatgen.org/pymatgen.core.html#pymatgen.core.ion.Ion)
14+
class to "translate" chemical formulas into a consistent format. Anything that the `Ion` class can understand will
15+
be processed into a valid formula by `pyEQL`.
16+
17+
Here are some examples:
18+
19+
| Substance | You enter | `pyEQL` understands |
20+
| :--- | :---: | :---: |
21+
| Sodium Chloride | "NaCl", "NaCl(aq)", or "ClNa" | "NaCl(aq)" |
22+
| Sodium Sulfate | "Na(SO4)2" or "NaS2O8" | "Na(SO4)2(aq)" |
23+
| Sodium Ion | "Na+", "Na+1", "Na1+", or "Na[+]" | "Na[+1]" |
24+
| Magnesium Ion | "Mg+2", "Mg++", or "Mg[++]" | "Mg[+2]" |
25+
| Methanol | "CH3OH", "CH4O" | "'CH3OH(aq)'" |
26+
27+
Specifically, `pyEQL` uses `Ion.from_formula(<formula>).reduced_formla` (shown in the right hand column of the table) to
28+
identify solutes. Notice that for charged species, the charges are always placed inside square brackets (e.g., `Na[+1]`)
29+
and always include the charge number (even for monovalent ions). Uncharged species are always suffixed by `(aq)` to
30+
disambiguate them from solids.
31+
32+
:::{important}
33+
**When writing multivalent ion formulas, it is strongly recommended that you put the charge number AFTER the + or -
34+
sign** (e.g., type "Mg+2" NOT "Mg2+"). The latter formula is ambiguous - it could mean $`Mg_2^+`$ or $`Mg^{+2}`$
35+
:::
36+
37+
(manual-testing)=
38+
## Manually testing a formula
39+
40+
If you want to make sure `pyEQL` is understanding your formula correctly, you can manually test it via `pymatgen` as
41+
follows:
42+
43+
```
44+
>>> from pymatgen.core.ion import Ion
45+
>>> Ion.from_formula(<your_formula>).reduced_formula
46+
...
47+
```
48+
49+
## Formulas you will see when using `Solution`
50+
51+
When using the `Solution` class,
52+
53+
- When creating a `Solution`, you can enter chemical formulas in any format you prefer, as long as `pymatgen` can understand it (see [manual testing](#manually-testing-a-formula)).
54+
- The keys (solute formulas) in `Solution.components` are preserved in the same format the user enters them. So if you entered `Na+` for sodium ion, it will stay that way.
55+
- Arguments to `Solution.get_property` can be entered in any format you prefer. When `pyEQL` queries the database, it will automatically convert the formula to the canonical one from `pymatgen`
56+
- Property data in the database is uniquely identified by the canonical ion formula (output of `Ion.from_formula(<formula>).reduced_formla`, e.g. "Na[+1]" for sodium ion).

docs/chemistry.rst

Lines changed: 0 additions & 58 deletions
This file was deleted.

docs/class_solute.rst

Lines changed: 0 additions & 7 deletions
This file was deleted.

docs/class_solution.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
(class-solution)=
2+
3+
# The Solution Class
4+
5+
The `Solution` class defines a pythonic interface for **creating**, **modifying**, and **estimating properties** of
6+
electrolyte solutions. It is the core feature of `pyEQL` and the primary user-facing class.
7+
8+
## Creating a solution
9+
10+
A `Solution` created with no arguments will default to pure water at pH=7, T=25 degrees Celsius, and 1 atm pressure.
11+
12+
```
13+
>>> from pyEQL import Solution
14+
>>> s1 = Solution()
15+
>>> s1.pH
16+
6.998877352386266
17+
```
18+
19+
Alternatively, you can use the `autogenerate()` function to easily create common solutions like seawater:
20+
21+
```
22+
>>> from pyEQL.functions import autogenerate
23+
>>> s2 = autogenerate('seawater')
24+
<pyEQL.solution.Solution object at 0x7f057de6b0a0>
25+
```
26+
27+
You can inspect the solutes present in the solution via the `components` attribute. This comprises a dictionary of solute formula: moles, where 'moles' is the number of moles of that solute in the `Solution`. Note that the solvent (water) is present in `components`, too.
28+
29+
```
30+
>>> s2.components
31+
{'H2O': 55.34455401423017,
32+
'H+': 7.943282347242822e-09,
33+
'OH-': 8.207436858780226e-06,
34+
'Na+': 0.46758273714962967,
35+
'Mg+2': 0.052661180523467986,
36+
'Ca+2': 0.010251594148212318,
37+
'K+': 0.010177468379526856,
38+
'Sr+2': 9.046483353663286e-05,
39+
'Cl-': 0.54425785619973,
40+
'SO4-2': 0.028151873448454025,
41+
'HCO3-': 0.001712651176926199,
42+
'Br-': 0.0008395244921424563,
43+
'CO3-2': 0.00023825904349479546,
44+
'B(OH)4': 0.0001005389715937341,
45+
'F-': 6.822478260456777e-05,
46+
'B(OH)3': 0.0003134669156396757,
47+
'CO2': 9.515218476861175e-06
48+
}
49+
```
50+
51+
To get the amount of a specific solute, use `get_amount()` and specify the units you want:
52+
53+
```
54+
>>> s2.get_amount('Na+', 'g/L')
55+
<Quantity(10.6636539, 'gram / liter')>
56+
```
57+
58+
Finally, you can manually create a solution with any list of solutes, temperature, pressure, etc. that you need:
59+
60+
```
61+
>>> from pyEQL import Solution
62+
>>> s1 = Solution(solutes={'Na+':'0.5 mol/kg', 'Cl-': '0.5 mol/kg'},
63+
pH=8,
64+
temperature = '20 degC',
65+
volume='8 L'
66+
)
67+
```
68+
69+
## Class reference
70+
71+
The remainder of this page contains detailed information on each of the methods, attributes, and properties in `Solution`. Use the sidebar on the right for easier navigation.
72+
73+
```{eval-rst}
74+
.. autoclass:: pyEQL.Solution
75+
:members:
76+
:inherited-members:
77+
:private-members: _get_property
78+
:special-members: __init__
79+
:member-order: bysource
80+
```

docs/class_solution.rst

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)