pcetera 0.1.0__tar.gz
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.
- pcetera-0.1.0/LICENSE +21 -0
- pcetera-0.1.0/PKG-INFO +127 -0
- pcetera-0.1.0/README.md +115 -0
- pcetera-0.1.0/pcetera/__init__.py +1 -0
- pcetera-0.1.0/pcetera/thermo.py +172 -0
- pcetera-0.1.0/pcetera.egg-info/PKG-INFO +127 -0
- pcetera-0.1.0/pcetera.egg-info/SOURCES.txt +13 -0
- pcetera-0.1.0/pcetera.egg-info/dependency_links.txt +1 -0
- pcetera-0.1.0/pcetera.egg-info/top_level.txt +1 -0
- pcetera-0.1.0/pyproject.toml +19 -0
- pcetera-0.1.0/setup.cfg +4 -0
- pcetera-0.1.0/tests/test_agarwal2022.py +90 -0
- pcetera-0.1.0/tests/test_thermo.py +174 -0
- pcetera-0.1.0/tests/test_warren2010.py +55 -0
- pcetera-0.1.0/tests/test_wiedner2016.py +76 -0
pcetera-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nathan Fong
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
pcetera-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pcetera
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Solution-phase proton, electron, hydrogen-atom and hydride transfer thermochemistry
|
|
5
|
+
Author: Nathan Fong
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Source, https://github.com/nvfong/pcetera
|
|
8
|
+
Requires-Python: >=3.11
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Dynamic: license-file
|
|
12
|
+
|
|
13
|
+
# PCETera
|
|
14
|
+
|
|
15
|
+
PCET, et cetera! An open source toolkit for solution-phase proton, electron, hydrogen-atom and hydride transfer thermochemistry.
|
|
16
|
+
|
|
17
|
+
PCETera turns solution free energies into pKa values, reduction potentials (E°), BDFEs and hydricities. Each one comes from the free energy of a single transfer:
|
|
18
|
+
|
|
19
|
+
pKa: XH -> X- + H+
|
|
20
|
+
potential: Red -> Ox + n e- (reported as the reduction potential of Ox/Red)
|
|
21
|
+
BDFE: XH -> X. + H.
|
|
22
|
+
hydricity: XH -> X+ + H-
|
|
23
|
+
|
|
24
|
+
These quantities are often worked out by hand using constants that depend on the solvent, reference electrode and literature source. Mixing constants can shift results by several kcal/mol (the 2010 and 2022 Chem. Rev. compilations differ in C_G by about 2–5 kcal/mol depending on the solvent).
|
|
25
|
+
|
|
26
|
+
PCETera keeps track of the reference set and solvent of labeled values and checks for mismatches when they are used in reference-set calculations.
|
|
27
|
+
|
|
28
|
+
PCETera is in early stage development. (0.1.0)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
## Install
|
|
32
|
+
|
|
33
|
+
Python 3.11 or newer, no other dependencies (at this time).
|
|
34
|
+
|
|
35
|
+
git clone https://github.com/nvfong/pcetera
|
|
36
|
+
cd pcetera
|
|
37
|
+
pip install .
|
|
38
|
+
|
|
39
|
+
OR
|
|
40
|
+
|
|
41
|
+
pip install git+https://github.com/nvfong/pcetera
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
## Usage
|
|
45
|
+
|
|
46
|
+
From your own solution free energies (kcal/mol, `thermo.to_kcal` converts from hartree, kJ/mol or eV):
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from pcetera import thermo
|
|
50
|
+
|
|
51
|
+
pka = thermo.pka(g_acid, g_base, g_proton)
|
|
52
|
+
e = thermo.potential(g_red, g_ox, g_electron, e_abs_ref, n=1)
|
|
53
|
+
bdfe = thermo.bdfe(g_xh, g_x, g_hatom)
|
|
54
|
+
hyd = thermo.hydricity(g_xh, g_xplus, g_hydride)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
You will input the free energies of H+, e-, H. and H- and the absolute potential of the reference electrode. The values for `g_electron` and `e_abs_ref` must use the same electron convention.
|
|
58
|
+
|
|
59
|
+
Example:
|
|
60
|
+
|
|
61
|
+
From measured pKa values and potentials, on a named reference set:
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
from pcetera import thermo
|
|
65
|
+
|
|
66
|
+
# Phenol in water (Agarwal 2022, Table 6): E(PhO./PhO-) = 0.79 V vs SHE, pKa = 10.0
|
|
67
|
+
h = thermo.get_h_ref("Agarwal 2022", "water", "SHE")
|
|
68
|
+
e = thermo.e_vs_h2_from_pka(10.0, 0.79, h) # PCET potential vs H+/H2: 1.38 V
|
|
69
|
+
thermo.bdfe_from_e_vs_h2(e, h) # BDFE: 84.7 kcal/mol
|
|
70
|
+
|
|
71
|
+
# HCo(dppe)2 in acetonitrile (Wiedner 2016, Scheme 15): pKa 38.9, E(Co0/Co-I) = -2.03 V, E(CoI/Co0) = -1.56 V
|
|
72
|
+
w = thermo.get_h_ref("Wiedner 2016", "mecn", "Fc+/Fc")
|
|
73
|
+
thermo.hydricity_from_pka(38.9, -2.03, -1.56, w) # 49.9 kcal/mol
|
|
74
|
+
|
|
75
|
+
# Passing a labeled result to a different reference set raises a ValueError
|
|
76
|
+
a = thermo.get_h_ref("Agarwal 2022", "mecn", "Fc+/Fc")
|
|
77
|
+
thermo.bdfe_from_e_vs_h2(thermo.e_vs_h2_from_pka(38.9, -2.03, w), a)
|
|
78
|
+
# ValueError: value from Wiedner 2016 in mecn, ...
|
|
79
|
+
```
|
|
80
|
+
Other functions in `thermo`:
|
|
81
|
+
|
|
82
|
+
- `on_set`: label a value taken from the literature with a reference set.
|
|
83
|
+
- `pka_from_bdfe`: calculate a pKa from a BDFE and potential.
|
|
84
|
+
- `bdfe_oxidized`: calculate the BDFE of the oxidized species (Wiedner 2016).
|
|
85
|
+
- `c_g`, `c_hyd`: access the reference constants.
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
## Notes/Conventions (as of November 29th, 2026)
|
|
89
|
+
|
|
90
|
+
- Energies in kcal/mol, solution phase, 1 M standard state. Potentials in V.
|
|
91
|
+
- Reference sets are treated as being at 298.15 K. `pka` takes a temperature while the reference pathways do not.
|
|
92
|
+
- Reference sets:
|
|
93
|
+
|
|
94
|
+
| Set | Solvent (code name) | Electrode | Source |
|
|
95
|
+
|---|---|---|---|
|
|
96
|
+
| `"Agarwal 2022"` | water (`water`) | SHE | Agarwal et al., Chem. Rev. 2022, 122, 1-49, Table 1 |
|
|
97
|
+
| | acetonitrile (`mecn`), DMSO (`dmso`), DMF (`dmf`), methanol (`meoh`), THF (`thf`) | Fc+/Fc | |
|
|
98
|
+
| `"Wiedner 2016"` | acetonitrile (`mecn`) | Fc+/Fc | Wiedner et al., Chem. Rev. 2016, 116, 8655, Table 1 |
|
|
99
|
+
| `"Warren 2010"` | water (`water`) | NHE | Warren, Tronic & Mayer, Chem. Rev. 2010, 110, 6961, Table 1 |
|
|
100
|
+
| | acetonitrile (`mecn`), DMSO (`dmso`), DMF (`dmf`), methanol (`meoh`) | Fc+/Fc | |
|
|
101
|
+
|
|
102
|
+
- The reference-set functions check the set and solvent of labeled values. Unlabeled numbers, arrays and arithmetic on results are not checked.
|
|
103
|
+
- No electrode conversions (`get_h_ref` only accepts the electrode a set uses for that solvent).
|
|
104
|
+
- Hydride reference constants are only available in `Wiedner 2016`. `hydricity_from_pka` and `bdfe_oxidized` require this set.
|
|
105
|
+
- `Warren 2010` can be used with `pka_from_bdfe` and `on_set`, but not with the potential vs H2, BDFE-from-potential-vs-H2 or hydride pathways. (Use `Agarwal 2022` for those)
|
|
106
|
+
|
|
107
|
+
## Citing
|
|
108
|
+
|
|
109
|
+
There's no paper yet, since I am still very early on in development. If you would like to use PCETera, please cite the repository and version:
|
|
110
|
+
|
|
111
|
+
Nathan Fong, PCETera (version 0.1.0), https://github.com/nvfong/pcetera
|
|
112
|
+
|
|
113
|
+
along with the source of the reference set you used:
|
|
114
|
+
|
|
115
|
+
- Agarwal et al., Chem. Rev. 2022, 122, 1-49
|
|
116
|
+
- Wiedner et al., Chem. Rev. 2016, 116, 8655
|
|
117
|
+
- Warren, Tronic & Mayer, Chem. Rev. 2010, 110, 6961
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
## Tests
|
|
121
|
+
|
|
122
|
+
python -m pip install . pytest
|
|
123
|
+
python -m pytest
|
|
124
|
+
|
|
125
|
+
## Licence
|
|
126
|
+
|
|
127
|
+
MIT, see `LICENSE`.
|
pcetera-0.1.0/README.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# PCETera
|
|
2
|
+
|
|
3
|
+
PCET, et cetera! An open source toolkit for solution-phase proton, electron, hydrogen-atom and hydride transfer thermochemistry.
|
|
4
|
+
|
|
5
|
+
PCETera turns solution free energies into pKa values, reduction potentials (E°), BDFEs and hydricities. Each one comes from the free energy of a single transfer:
|
|
6
|
+
|
|
7
|
+
pKa: XH -> X- + H+
|
|
8
|
+
potential: Red -> Ox + n e- (reported as the reduction potential of Ox/Red)
|
|
9
|
+
BDFE: XH -> X. + H.
|
|
10
|
+
hydricity: XH -> X+ + H-
|
|
11
|
+
|
|
12
|
+
These quantities are often worked out by hand using constants that depend on the solvent, reference electrode and literature source. Mixing constants can shift results by several kcal/mol (the 2010 and 2022 Chem. Rev. compilations differ in C_G by about 2–5 kcal/mol depending on the solvent).
|
|
13
|
+
|
|
14
|
+
PCETera keeps track of the reference set and solvent of labeled values and checks for mismatches when they are used in reference-set calculations.
|
|
15
|
+
|
|
16
|
+
PCETera is in early stage development. (0.1.0)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
Python 3.11 or newer, no other dependencies (at this time).
|
|
22
|
+
|
|
23
|
+
git clone https://github.com/nvfong/pcetera
|
|
24
|
+
cd pcetera
|
|
25
|
+
pip install .
|
|
26
|
+
|
|
27
|
+
OR
|
|
28
|
+
|
|
29
|
+
pip install git+https://github.com/nvfong/pcetera
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
From your own solution free energies (kcal/mol, `thermo.to_kcal` converts from hartree, kJ/mol or eV):
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
from pcetera import thermo
|
|
38
|
+
|
|
39
|
+
pka = thermo.pka(g_acid, g_base, g_proton)
|
|
40
|
+
e = thermo.potential(g_red, g_ox, g_electron, e_abs_ref, n=1)
|
|
41
|
+
bdfe = thermo.bdfe(g_xh, g_x, g_hatom)
|
|
42
|
+
hyd = thermo.hydricity(g_xh, g_xplus, g_hydride)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
You will input the free energies of H+, e-, H. and H- and the absolute potential of the reference electrode. The values for `g_electron` and `e_abs_ref` must use the same electron convention.
|
|
46
|
+
|
|
47
|
+
Example:
|
|
48
|
+
|
|
49
|
+
From measured pKa values and potentials, on a named reference set:
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from pcetera import thermo
|
|
53
|
+
|
|
54
|
+
# Phenol in water (Agarwal 2022, Table 6): E(PhO./PhO-) = 0.79 V vs SHE, pKa = 10.0
|
|
55
|
+
h = thermo.get_h_ref("Agarwal 2022", "water", "SHE")
|
|
56
|
+
e = thermo.e_vs_h2_from_pka(10.0, 0.79, h) # PCET potential vs H+/H2: 1.38 V
|
|
57
|
+
thermo.bdfe_from_e_vs_h2(e, h) # BDFE: 84.7 kcal/mol
|
|
58
|
+
|
|
59
|
+
# HCo(dppe)2 in acetonitrile (Wiedner 2016, Scheme 15): pKa 38.9, E(Co0/Co-I) = -2.03 V, E(CoI/Co0) = -1.56 V
|
|
60
|
+
w = thermo.get_h_ref("Wiedner 2016", "mecn", "Fc+/Fc")
|
|
61
|
+
thermo.hydricity_from_pka(38.9, -2.03, -1.56, w) # 49.9 kcal/mol
|
|
62
|
+
|
|
63
|
+
# Passing a labeled result to a different reference set raises a ValueError
|
|
64
|
+
a = thermo.get_h_ref("Agarwal 2022", "mecn", "Fc+/Fc")
|
|
65
|
+
thermo.bdfe_from_e_vs_h2(thermo.e_vs_h2_from_pka(38.9, -2.03, w), a)
|
|
66
|
+
# ValueError: value from Wiedner 2016 in mecn, ...
|
|
67
|
+
```
|
|
68
|
+
Other functions in `thermo`:
|
|
69
|
+
|
|
70
|
+
- `on_set`: label a value taken from the literature with a reference set.
|
|
71
|
+
- `pka_from_bdfe`: calculate a pKa from a BDFE and potential.
|
|
72
|
+
- `bdfe_oxidized`: calculate the BDFE of the oxidized species (Wiedner 2016).
|
|
73
|
+
- `c_g`, `c_hyd`: access the reference constants.
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
## Notes/Conventions (as of November 29th, 2026)
|
|
77
|
+
|
|
78
|
+
- Energies in kcal/mol, solution phase, 1 M standard state. Potentials in V.
|
|
79
|
+
- Reference sets are treated as being at 298.15 K. `pka` takes a temperature while the reference pathways do not.
|
|
80
|
+
- Reference sets:
|
|
81
|
+
|
|
82
|
+
| Set | Solvent (code name) | Electrode | Source |
|
|
83
|
+
|---|---|---|---|
|
|
84
|
+
| `"Agarwal 2022"` | water (`water`) | SHE | Agarwal et al., Chem. Rev. 2022, 122, 1-49, Table 1 |
|
|
85
|
+
| | acetonitrile (`mecn`), DMSO (`dmso`), DMF (`dmf`), methanol (`meoh`), THF (`thf`) | Fc+/Fc | |
|
|
86
|
+
| `"Wiedner 2016"` | acetonitrile (`mecn`) | Fc+/Fc | Wiedner et al., Chem. Rev. 2016, 116, 8655, Table 1 |
|
|
87
|
+
| `"Warren 2010"` | water (`water`) | NHE | Warren, Tronic & Mayer, Chem. Rev. 2010, 110, 6961, Table 1 |
|
|
88
|
+
| | acetonitrile (`mecn`), DMSO (`dmso`), DMF (`dmf`), methanol (`meoh`) | Fc+/Fc | |
|
|
89
|
+
|
|
90
|
+
- The reference-set functions check the set and solvent of labeled values. Unlabeled numbers, arrays and arithmetic on results are not checked.
|
|
91
|
+
- No electrode conversions (`get_h_ref` only accepts the electrode a set uses for that solvent).
|
|
92
|
+
- Hydride reference constants are only available in `Wiedner 2016`. `hydricity_from_pka` and `bdfe_oxidized` require this set.
|
|
93
|
+
- `Warren 2010` can be used with `pka_from_bdfe` and `on_set`, but not with the potential vs H2, BDFE-from-potential-vs-H2 or hydride pathways. (Use `Agarwal 2022` for those)
|
|
94
|
+
|
|
95
|
+
## Citing
|
|
96
|
+
|
|
97
|
+
There's no paper yet, since I am still very early on in development. If you would like to use PCETera, please cite the repository and version:
|
|
98
|
+
|
|
99
|
+
Nathan Fong, PCETera (version 0.1.0), https://github.com/nvfong/pcetera
|
|
100
|
+
|
|
101
|
+
along with the source of the reference set you used:
|
|
102
|
+
|
|
103
|
+
- Agarwal et al., Chem. Rev. 2022, 122, 1-49
|
|
104
|
+
- Wiedner et al., Chem. Rev. 2016, 116, 8655
|
|
105
|
+
- Warren, Tronic & Mayer, Chem. Rev. 2010, 110, 6961
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
## Tests
|
|
109
|
+
|
|
110
|
+
python -m pip install . pytest
|
|
111
|
+
python -m pytest
|
|
112
|
+
|
|
113
|
+
## Licence
|
|
114
|
+
|
|
115
|
+
MIT, see `LICENSE`.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""PCETera: PCET, et cetera"""
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
thermo.py
|
|
4
|
+
|
|
5
|
+
Solution free energies -> pKa, reduction potentials, BDFEs, hydricities.
|
|
6
|
+
Each one is the free energy of a single transfer, written as a loss:
|
|
7
|
+
pKa: XH -> X- + H+
|
|
8
|
+
potential: Red -> Ox + n e- (reported as the reduction potential of Ox/Red)
|
|
9
|
+
BDFE: XH -> X. + H.
|
|
10
|
+
hydricity: XH -> X+ + H-
|
|
11
|
+
|
|
12
|
+
Energies in kcal/mol, solution phase, 1 M standard state.
|
|
13
|
+
Absolute reference values (G of H+, e-, H., H-, electrode potential) come from the caller.
|
|
14
|
+
H_REF holds cited relative values (298.15 K), picked by set, solvent & electrode w/ get_h_ref.
|
|
15
|
+
Results from one set should not be combined w/ another (MeCN C_G is 52.65 in Agarwal 2022, 53.6 in Wiedner 2016).
|
|
16
|
+
Functions taking h refuse a result or on_set value from another set or solvent (plain numbers, arrays & math on results aren't checked).
|
|
17
|
+
|
|
18
|
+
@author: Nathan Fong
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
### Python modules to import
|
|
22
|
+
import math
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Physical constants (2019 SI, exact except the hartree)
|
|
26
|
+
N_A = 6.02214076e23 # Avogadro constant (1/mol)
|
|
27
|
+
K_B = 1.380649e-23 # Boltzmann constant (J/K)
|
|
28
|
+
Q_E = 1.602176634e-19 # Elementary charge (C)
|
|
29
|
+
CAL = 4.184 # Thermochemical calorie (J)
|
|
30
|
+
E_H = 4.3597447222071e-18 # Hartree energy (J), CODATA 2018
|
|
31
|
+
|
|
32
|
+
### Derived constants in kcal/mol
|
|
33
|
+
R = N_A * K_B / (1000 * CAL) # Gas constant, kcal/(mol K), ~0.0019872
|
|
34
|
+
F = N_A * Q_E / (1000 * CAL) # Faraday constant, kcal/(mol V), ~23.0605
|
|
35
|
+
HARTREE = N_A * E_H / (1000 * CAL) # 1 hartree in kcal/mol, ~627.5095
|
|
36
|
+
LN10 = math.log(10)
|
|
37
|
+
|
|
38
|
+
### Unit conversions to kcal/mol
|
|
39
|
+
TO_KCAL = {"kcal/mol": 1.0,
|
|
40
|
+
"kj/mol": 1 / CAL,
|
|
41
|
+
"hartree": HARTREE,
|
|
42
|
+
"ev": F} # eV per molecule, numerically the same as F
|
|
43
|
+
|
|
44
|
+
### H+/H./H- reference values per set & solvent
|
|
45
|
+
### ref: electrode for that solvent's potentials, dgf_h: dGf(H.) in solution (kcal/mol), e_h2: E(H+/H2) in V vs ref
|
|
46
|
+
### c_g: C_G in kcal/mol, only in sets that give C_G w/o dGf(H.) & E(H+/H2)
|
|
47
|
+
### dg_hminus: dG of H. + e- -> H- in kcal/mol (C_hyd - C_G), only in sets w/ hydride values
|
|
48
|
+
T_REF = 298.15 # Temperature of all H_REF values (K)
|
|
49
|
+
H_REF = {
|
|
50
|
+
# Agarwal et al., Chem. Rev. 2022, 122, 1-49, Table 1
|
|
51
|
+
"Agarwal 2022": {"water": {"ref": "SHE", "dgf_h": 52.8, "e_h2": 0.0},
|
|
52
|
+
"mecn": {"ref": "Fc+/Fc", "dgf_h": 52.0, "e_h2": -0.028},
|
|
53
|
+
"dmso": {"ref": "Fc+/Fc", "dgf_h": 52.6, "e_h2": -0.67}, # From a quasi-reversible wave, lower precision (Table 1 footnote)
|
|
54
|
+
"dmf": {"ref": "Fc+/Fc", "dgf_h": 52.3, "e_h2": -0.662},
|
|
55
|
+
"meoh": {"ref": "Fc+/Fc", "dgf_h": 51.9, "e_h2": -0.501},
|
|
56
|
+
"thf": {"ref": "Fc+/Fc", "dgf_h": 52.0, "e_h2": -0.343}},
|
|
57
|
+
# Wiedner et al., Chem. Rev. 2016, 116, 8655, Table 1 (2H+ + 2e- -> H2 3.6, H2 -> 2H. 103.6, H. + e- -> H- 26.0)
|
|
58
|
+
"Wiedner 2016": {"mecn": {"ref": "Fc+/Fc", "dgf_h": 103.6 / 2, "e_h2": -3.6 / (2 * F), "dg_hminus": 26.0}},
|
|
59
|
+
# Warren et al., Chem. Rev. 2010, 110, 6961, Table 1 (C_G only, water vs NHE as printed)
|
|
60
|
+
# Superseded by Agarwal 2022 (correction: Chem. Rev. 2022, 122, 1482), kept for values printed w/ these constants
|
|
61
|
+
"Warren 2010": {"water": {"ref": "NHE", "c_g": 57.6},
|
|
62
|
+
"mecn": {"ref": "Fc+/Fc", "c_g": 54.9},
|
|
63
|
+
"dmso": {"ref": "Fc+/Fc", "c_g": 71.1},
|
|
64
|
+
"dmf": {"ref": "Fc+/Fc", "c_g": 69.7},
|
|
65
|
+
"meoh": {"ref": "Fc+/Fc", "c_g": 65.3}}}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def to_kcal(value, unit):
|
|
69
|
+
"""Convert an energy (or numpy array of energies) to kcal/mol"""
|
|
70
|
+
return value * TO_KCAL[unit.lower()]
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def _dg_loss(g_start, g_end, g_particle, n=1):
|
|
74
|
+
"""Return free energy of start -> end + n particles"""
|
|
75
|
+
return g_end + n * g_particle - g_start
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def pka(g_acid, g_base, g_proton, temp=298.15):
|
|
79
|
+
"""Return pKa of XH -> X- + H+"""
|
|
80
|
+
return _dg_loss(g_acid, g_base, g_proton) / (R * temp * LN10)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def potential(g_red, g_ox, g_electron, e_abs_ref, n):
|
|
84
|
+
"""Return reduction potential (V) of Ox/Red vs a reference electrode whose absolute potential is e_abs_ref (V)
|
|
85
|
+
g_electron & e_abs_ref must use the same electron convention"""
|
|
86
|
+
return _dg_loss(g_red, g_ox, g_electron, n) / (n * F) - e_abs_ref
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def bdfe(g_xh, g_x, g_hatom):
|
|
90
|
+
"""Return bond dissociation free energy of XH -> X. + H."""
|
|
91
|
+
return _dg_loss(g_xh, g_x, g_hatom)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def hydricity(g_xh, g_xplus, g_hydride):
|
|
95
|
+
"""Return hydricity of XH -> X+ + H-"""
|
|
96
|
+
return _dg_loss(g_xh, g_xplus, g_hydride)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def get_h_ref(ref_set, solvent, ref):
|
|
100
|
+
"""Return H_REF values of one set for a solvent, ref must be that set's electrode (no conversions)"""
|
|
101
|
+
h = H_REF[ref_set][solvent]
|
|
102
|
+
if ref != h["ref"]:
|
|
103
|
+
raise ValueError(f"{ref_set} potentials in {solvent} are vs {h['ref']}, got '{ref}'")
|
|
104
|
+
return dict(h, set=ref_set, solvent=solvent)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
### Class to mark results w/ the set & solvent of their H_REF values
|
|
108
|
+
class RefValue(float):
|
|
109
|
+
"""Float w/ h_ref = (set, solvent)"""
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def _mark(value, h):
|
|
113
|
+
"""Return value as a RefValue on h's set & solvent (arrays & h w/o a set returned as is)"""
|
|
114
|
+
if not isinstance(value, float) or "set" not in h:
|
|
115
|
+
return value
|
|
116
|
+
x = RefValue(value)
|
|
117
|
+
x.h_ref = (h["set"], h["solvent"])
|
|
118
|
+
return x
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def _check(value, h):
|
|
122
|
+
"""Raise ValueError if value is a RefValue from another set or solvent than h (h w/o a set not checked)"""
|
|
123
|
+
if isinstance(value, RefValue) and "set" in h and value.h_ref != (h["set"], h["solvent"]):
|
|
124
|
+
raise ValueError(f"value from {value.h_ref[0]} in {value.h_ref[1]}, h is {h['set']} in {h['solvent']}")
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def on_set(value, h):
|
|
128
|
+
"""Return a typed value derived w/ h's set & solvent (e.g. a printed BDFE) as a RefValue"""
|
|
129
|
+
_check(value, h)
|
|
130
|
+
x = RefValue(value)
|
|
131
|
+
x.h_ref = (h["set"], h["solvent"])
|
|
132
|
+
return x
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def c_g(h):
|
|
136
|
+
"""Return C_G = dGf(H.) - F E(H+/H2), the free energy of H+ + e- -> H. (kcal/mol), or the stored C_G of a set w/ C_G only"""
|
|
137
|
+
if "c_g" in h:
|
|
138
|
+
return h["c_g"]
|
|
139
|
+
return h["dgf_h"] - F * h["e_h2"]
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def c_hyd(h):
|
|
143
|
+
"""Return C_hyd = C_G + dG(H. + e- -> H-), the free energy of H+ + 2e- -> H- (kcal/mol)"""
|
|
144
|
+
return c_g(h) + h["dg_hminus"]
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def e_vs_h2_from_pka(pka_xh, e_red, h):
|
|
148
|
+
"""Return PCET potential of X. + H+ + e- -> XH vs H+/H2 in the same solvent (V), from pKa(XH) & E(X./X-)"""
|
|
149
|
+
return _mark(e_red + R * T_REF * LN10 / F * pka_xh - h["e_h2"], h)
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def bdfe_from_e_vs_h2(e_vs_h2, h):
|
|
153
|
+
"""Return BDFE of XH from its PCET potential vs H+/H2 (Agarwal 2022, eq 18)"""
|
|
154
|
+
_check(e_vs_h2, h)
|
|
155
|
+
return _mark(F * e_vs_h2 + h["dgf_h"], h)
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def pka_from_bdfe(bdfe_xh, e_red, h):
|
|
159
|
+
"""Return pKa of XH from its BDFE & E(X./X-) (square scheme backwards)"""
|
|
160
|
+
_check(bdfe_xh, h)
|
|
161
|
+
return (bdfe_xh - F * e_red - c_g(h)) / (R * T_REF * LN10)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def hydricity_from_pka(pka_xh, e_red, e_xplus, h):
|
|
165
|
+
"""Return hydricity of XH from pKa(XH), e_red = E(X./X-) & e_xplus = E(X+/X.) (Wiedner 2016, Scheme 8)"""
|
|
166
|
+
return _mark(R * T_REF * LN10 * pka_xh + F * (e_red + e_xplus) + c_hyd(h), h)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def bdfe_oxidized(hydricity_xh, e_xh, h):
|
|
170
|
+
"""Return BDFE of XH.+ (XH minus one e-) from the hydricity of XH & E(XH.+/XH)"""
|
|
171
|
+
_check(hydricity_xh, h)
|
|
172
|
+
return _mark(hydricity_xh - F * e_xh - (c_hyd(h) - c_g(h)), h)
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pcetera
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Solution-phase proton, electron, hydrogen-atom and hydride transfer thermochemistry
|
|
5
|
+
Author: Nathan Fong
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Source, https://github.com/nvfong/pcetera
|
|
8
|
+
Requires-Python: >=3.11
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Dynamic: license-file
|
|
12
|
+
|
|
13
|
+
# PCETera
|
|
14
|
+
|
|
15
|
+
PCET, et cetera! An open source toolkit for solution-phase proton, electron, hydrogen-atom and hydride transfer thermochemistry.
|
|
16
|
+
|
|
17
|
+
PCETera turns solution free energies into pKa values, reduction potentials (E°), BDFEs and hydricities. Each one comes from the free energy of a single transfer:
|
|
18
|
+
|
|
19
|
+
pKa: XH -> X- + H+
|
|
20
|
+
potential: Red -> Ox + n e- (reported as the reduction potential of Ox/Red)
|
|
21
|
+
BDFE: XH -> X. + H.
|
|
22
|
+
hydricity: XH -> X+ + H-
|
|
23
|
+
|
|
24
|
+
These quantities are often worked out by hand using constants that depend on the solvent, reference electrode and literature source. Mixing constants can shift results by several kcal/mol (the 2010 and 2022 Chem. Rev. compilations differ in C_G by about 2–5 kcal/mol depending on the solvent).
|
|
25
|
+
|
|
26
|
+
PCETera keeps track of the reference set and solvent of labeled values and checks for mismatches when they are used in reference-set calculations.
|
|
27
|
+
|
|
28
|
+
PCETera is in early stage development. (0.1.0)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
## Install
|
|
32
|
+
|
|
33
|
+
Python 3.11 or newer, no other dependencies (at this time).
|
|
34
|
+
|
|
35
|
+
git clone https://github.com/nvfong/pcetera
|
|
36
|
+
cd pcetera
|
|
37
|
+
pip install .
|
|
38
|
+
|
|
39
|
+
OR
|
|
40
|
+
|
|
41
|
+
pip install git+https://github.com/nvfong/pcetera
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
## Usage
|
|
45
|
+
|
|
46
|
+
From your own solution free energies (kcal/mol, `thermo.to_kcal` converts from hartree, kJ/mol or eV):
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from pcetera import thermo
|
|
50
|
+
|
|
51
|
+
pka = thermo.pka(g_acid, g_base, g_proton)
|
|
52
|
+
e = thermo.potential(g_red, g_ox, g_electron, e_abs_ref, n=1)
|
|
53
|
+
bdfe = thermo.bdfe(g_xh, g_x, g_hatom)
|
|
54
|
+
hyd = thermo.hydricity(g_xh, g_xplus, g_hydride)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
You will input the free energies of H+, e-, H. and H- and the absolute potential of the reference electrode. The values for `g_electron` and `e_abs_ref` must use the same electron convention.
|
|
58
|
+
|
|
59
|
+
Example:
|
|
60
|
+
|
|
61
|
+
From measured pKa values and potentials, on a named reference set:
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
from pcetera import thermo
|
|
65
|
+
|
|
66
|
+
# Phenol in water (Agarwal 2022, Table 6): E(PhO./PhO-) = 0.79 V vs SHE, pKa = 10.0
|
|
67
|
+
h = thermo.get_h_ref("Agarwal 2022", "water", "SHE")
|
|
68
|
+
e = thermo.e_vs_h2_from_pka(10.0, 0.79, h) # PCET potential vs H+/H2: 1.38 V
|
|
69
|
+
thermo.bdfe_from_e_vs_h2(e, h) # BDFE: 84.7 kcal/mol
|
|
70
|
+
|
|
71
|
+
# HCo(dppe)2 in acetonitrile (Wiedner 2016, Scheme 15): pKa 38.9, E(Co0/Co-I) = -2.03 V, E(CoI/Co0) = -1.56 V
|
|
72
|
+
w = thermo.get_h_ref("Wiedner 2016", "mecn", "Fc+/Fc")
|
|
73
|
+
thermo.hydricity_from_pka(38.9, -2.03, -1.56, w) # 49.9 kcal/mol
|
|
74
|
+
|
|
75
|
+
# Passing a labeled result to a different reference set raises a ValueError
|
|
76
|
+
a = thermo.get_h_ref("Agarwal 2022", "mecn", "Fc+/Fc")
|
|
77
|
+
thermo.bdfe_from_e_vs_h2(thermo.e_vs_h2_from_pka(38.9, -2.03, w), a)
|
|
78
|
+
# ValueError: value from Wiedner 2016 in mecn, ...
|
|
79
|
+
```
|
|
80
|
+
Other functions in `thermo`:
|
|
81
|
+
|
|
82
|
+
- `on_set`: label a value taken from the literature with a reference set.
|
|
83
|
+
- `pka_from_bdfe`: calculate a pKa from a BDFE and potential.
|
|
84
|
+
- `bdfe_oxidized`: calculate the BDFE of the oxidized species (Wiedner 2016).
|
|
85
|
+
- `c_g`, `c_hyd`: access the reference constants.
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
## Notes/Conventions (as of November 29th, 2026)
|
|
89
|
+
|
|
90
|
+
- Energies in kcal/mol, solution phase, 1 M standard state. Potentials in V.
|
|
91
|
+
- Reference sets are treated as being at 298.15 K. `pka` takes a temperature while the reference pathways do not.
|
|
92
|
+
- Reference sets:
|
|
93
|
+
|
|
94
|
+
| Set | Solvent (code name) | Electrode | Source |
|
|
95
|
+
|---|---|---|---|
|
|
96
|
+
| `"Agarwal 2022"` | water (`water`) | SHE | Agarwal et al., Chem. Rev. 2022, 122, 1-49, Table 1 |
|
|
97
|
+
| | acetonitrile (`mecn`), DMSO (`dmso`), DMF (`dmf`), methanol (`meoh`), THF (`thf`) | Fc+/Fc | |
|
|
98
|
+
| `"Wiedner 2016"` | acetonitrile (`mecn`) | Fc+/Fc | Wiedner et al., Chem. Rev. 2016, 116, 8655, Table 1 |
|
|
99
|
+
| `"Warren 2010"` | water (`water`) | NHE | Warren, Tronic & Mayer, Chem. Rev. 2010, 110, 6961, Table 1 |
|
|
100
|
+
| | acetonitrile (`mecn`), DMSO (`dmso`), DMF (`dmf`), methanol (`meoh`) | Fc+/Fc | |
|
|
101
|
+
|
|
102
|
+
- The reference-set functions check the set and solvent of labeled values. Unlabeled numbers, arrays and arithmetic on results are not checked.
|
|
103
|
+
- No electrode conversions (`get_h_ref` only accepts the electrode a set uses for that solvent).
|
|
104
|
+
- Hydride reference constants are only available in `Wiedner 2016`. `hydricity_from_pka` and `bdfe_oxidized` require this set.
|
|
105
|
+
- `Warren 2010` can be used with `pka_from_bdfe` and `on_set`, but not with the potential vs H2, BDFE-from-potential-vs-H2 or hydride pathways. (Use `Agarwal 2022` for those)
|
|
106
|
+
|
|
107
|
+
## Citing
|
|
108
|
+
|
|
109
|
+
There's no paper yet, since I am still very early on in development. If you would like to use PCETera, please cite the repository and version:
|
|
110
|
+
|
|
111
|
+
Nathan Fong, PCETera (version 0.1.0), https://github.com/nvfong/pcetera
|
|
112
|
+
|
|
113
|
+
along with the source of the reference set you used:
|
|
114
|
+
|
|
115
|
+
- Agarwal et al., Chem. Rev. 2022, 122, 1-49
|
|
116
|
+
- Wiedner et al., Chem. Rev. 2016, 116, 8655
|
|
117
|
+
- Warren, Tronic & Mayer, Chem. Rev. 2010, 110, 6961
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
## Tests
|
|
121
|
+
|
|
122
|
+
python -m pip install . pytest
|
|
123
|
+
python -m pytest
|
|
124
|
+
|
|
125
|
+
## Licence
|
|
126
|
+
|
|
127
|
+
MIT, see `LICENSE`.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
pcetera/__init__.py
|
|
5
|
+
pcetera/thermo.py
|
|
6
|
+
pcetera.egg-info/PKG-INFO
|
|
7
|
+
pcetera.egg-info/SOURCES.txt
|
|
8
|
+
pcetera.egg-info/dependency_links.txt
|
|
9
|
+
pcetera.egg-info/top_level.txt
|
|
10
|
+
tests/test_agarwal2022.py
|
|
11
|
+
tests/test_thermo.py
|
|
12
|
+
tests/test_warren2010.py
|
|
13
|
+
tests/test_wiedner2016.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pcetera
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "pcetera"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Solution-phase proton, electron, hydrogen-atom and hydride transfer thermochemistry"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
authors = [{name = "Nathan Fong"}]
|
|
13
|
+
requires-python = ">=3.11"
|
|
14
|
+
|
|
15
|
+
[project.urls]
|
|
16
|
+
Source = "https://github.com/nvfong/pcetera"
|
|
17
|
+
|
|
18
|
+
[tool.setuptools]
|
|
19
|
+
packages = ["pcetera"]
|
pcetera-0.1.0/setup.cfg
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Tests against Agarwal et al., Chem. Rev. 2022, 122, 1-49
|
|
4
|
+
|
|
5
|
+
Values kept as printed (strings), tolerances can follow the printed digits.
|
|
6
|
+
The source rounded its coefficients (0.0592 V per pKa unit, 23.06). Not done here which
|
|
7
|
+
makes D = 0.0592 - RT ln10/F = 0.0000407 V per pKa unit on top of the rounding.
|
|
8
|
+
|
|
9
|
+
@author: Nathan Fong
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import pytest
|
|
13
|
+
from pcetera import thermo
|
|
14
|
+
|
|
15
|
+
D = 0.0592 - thermo.R * 298.15 * thermo.LN10 / thermo.F # Source's rounded 0.0592 vs exact, ~0.0000407 V
|
|
16
|
+
MECN = thermo.get_h_ref("Agarwal 2022", "mecn", "Fc+/Fc")
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _unit(printed):
|
|
20
|
+
"""Return one unit in the last printed digit, e.g. '10.1' -> 0.1, '-0.674' -> 0.001, '66' -> 1"""
|
|
21
|
+
return 10.0 ** -len(printed.split(".")[1]) if "." in printed else 1.0
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Table 1: solvent, electrode, dGf(H.), E(H+/H2), C_G
|
|
25
|
+
TABLE1 = [("water", "SHE", "52.8", "0.00", "52.8"),
|
|
26
|
+
("mecn", "Fc+/Fc", "52.0", "-0.028", "52.6"),
|
|
27
|
+
("dmso", "Fc+/Fc", "52.6", "-0.67", "68"),
|
|
28
|
+
("dmf", "Fc+/Fc", "52.3", "-0.662", "67.6"),
|
|
29
|
+
("meoh", "Fc+/Fc", "51.9", "-0.501", "63.4"), # No worked row for MeOH in any table
|
|
30
|
+
("thf", "Fc+/Fc", "52.0", "-0.343", "59.9")]
|
|
31
|
+
|
|
32
|
+
### Check the stored pair against Table 1 as printed (typo guard), then C_G from it against the C_G column
|
|
33
|
+
### Half a unit for the printed C_G, plus 0.06 for rounding of dGf(H.) & E(H+/H2)
|
|
34
|
+
@pytest.mark.parametrize("solvent, ref, dgf_h, e_h2, c_g", TABLE1)
|
|
35
|
+
def test_table1(solvent, ref, dgf_h, e_h2, c_g):
|
|
36
|
+
h = thermo.get_h_ref("Agarwal 2022", solvent, ref)
|
|
37
|
+
assert (h["dgf_h"], h["e_h2"]) == (float(dgf_h), float(e_h2))
|
|
38
|
+
assert thermo.c_g(h) == pytest.approx(float(c_g), abs=0.5 * _unit(c_g) + 0.06)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
### Rows from Table 6 (Table 5 for H2NOH, Table 23 for LGCuOH): name, solvent, electrode, E(X./X-), pKa(XH), E vs H2, BDFE
|
|
42
|
+
ROWS = [("phenol", "water", "SHE", "0.79", "10.0", "1.38", "84.7"),
|
|
43
|
+
("4-methoxyphenol", "water", "SHE", "0.54", "10.1", "1.14", "79.0"),
|
|
44
|
+
("4-nitrophenol", "water", "SHE", "1.22", "7.1", "1.64", "90.6"),
|
|
45
|
+
("2,4,6-tBu3-phenol", "dmso", "Fc+/Fc", "-0.674", "17.8", "1.050", "76.8"), # Table 6, footnote i
|
|
46
|
+
("4-aminophenol", "dmso", "Fc+/Fc", "-1.060", "20.75", "0.839", "71.9"), # Printed E vs H2 is a unit high either way
|
|
47
|
+
("H2NOH", "water", "SHE", "0.09", "13.7", "0.90", "73.6"),
|
|
48
|
+
("LGCuOH", "thf", "Fc+/Fc", "-0.074", "18.8", "1.382", "83.9")]
|
|
49
|
+
|
|
50
|
+
@pytest.mark.parametrize("name, solvent, ref, e, pka, e_vs_h2, bdfe", ROWS)
|
|
51
|
+
def test_square_scheme_rows(name, solvent, ref, e, pka, e_vs_h2, bdfe):
|
|
52
|
+
h = thermo.get_h_ref("Agarwal 2022", solvent, ref)
|
|
53
|
+
slack = D * float(pka)
|
|
54
|
+
e_vs_h2_calc = thermo.e_vs_h2_from_pka(float(pka), float(e), h)
|
|
55
|
+
assert e_vs_h2_calc == pytest.approx(float(e_vs_h2), abs=_unit(e_vs_h2) + slack)
|
|
56
|
+
assert thermo.bdfe_from_e_vs_h2(e_vs_h2_calc, h) == pytest.approx(float(bdfe), abs=0.5 * _unit(bdfe) + thermo.F * slack)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
### Rows w/ E vs H2 measured, so eq 18 only: name, solvent, electrode, E vs H2, BDFE
|
|
60
|
+
EQ18_ROWS = [("TEMPOH", "mecn", "Fc+/Fc", "0.60", "66"), # Table 5
|
|
61
|
+
("CO2/CO", "dmf", "Fc+/Fc", "-0.068", "50.7"), # Table 21, -dG/n per H
|
|
62
|
+
("4-methoxy-2,6-tBu2-phenol", "thf", "Fc+/Fc", "0.838", "71.3")] # Table 6
|
|
63
|
+
|
|
64
|
+
@pytest.mark.parametrize("name, solvent, ref, e_vs_h2, bdfe", EQ18_ROWS)
|
|
65
|
+
def test_eq18_rows(name, solvent, ref, e_vs_h2, bdfe):
|
|
66
|
+
h = thermo.get_h_ref("Agarwal 2022", solvent, ref)
|
|
67
|
+
assert thermo.bdfe_from_e_vs_h2(float(e_vs_h2), h) == pytest.approx(float(bdfe), abs=0.5 * _unit(bdfe))
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
### Check 2,4,6-tBu3-phenol in MeCN (Table 6) stays ~0.6 kcal/mol open
|
|
71
|
+
### pKa (28) extrapolated from DMSO & E (-0.67) back-calculated, vs measured E vs H2 of 0.99
|
|
72
|
+
def test_open_loop_tbu3_mecn():
|
|
73
|
+
via_pka = thermo.bdfe_from_e_vs_h2(thermo.e_vs_h2_from_pka(28, -0.67, MECN), MECN)
|
|
74
|
+
measured = thermo.bdfe_from_e_vs_h2(0.99, MECN)
|
|
75
|
+
assert via_pka - measured == pytest.approx(0.56, abs=0.01)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
### Check refusals: wrong electrode, unknown solvent or set, hydride constant from a set w/o one, E vs H2 from another solvent
|
|
79
|
+
def test_refuses():
|
|
80
|
+
with pytest.raises(ValueError):
|
|
81
|
+
thermo.get_h_ref("Agarwal 2022", "dmso", "SHE")
|
|
82
|
+
with pytest.raises(KeyError):
|
|
83
|
+
thermo.get_h_ref("Agarwal 2022", "benzene", "SHE")
|
|
84
|
+
with pytest.raises(KeyError):
|
|
85
|
+
thermo.get_h_ref("made up", "mecn", "Fc+/Fc")
|
|
86
|
+
with pytest.raises(KeyError):
|
|
87
|
+
thermo.c_hyd(MECN)
|
|
88
|
+
dmso_e_vs_h2 = thermo.e_vs_h2_from_pka(17.8, -0.674, thermo.get_h_ref("Agarwal 2022", "dmso", "Fc+/Fc")) # 2,4,6-tBu3-phenol
|
|
89
|
+
with pytest.raises(ValueError):
|
|
90
|
+
thermo.bdfe_from_e_vs_h2(dmso_e_vs_h2, MECN)
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Tests for thermo.py
|
|
4
|
+
|
|
5
|
+
Doesn't use real energies, loop tests check identities that hold for any numbers,
|
|
6
|
+
so they catch sign/bookkeeping errors
|
|
7
|
+
|
|
8
|
+
@author: Nathan Fong
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
### Python modules to import
|
|
12
|
+
import copy
|
|
13
|
+
import pickle
|
|
14
|
+
import random
|
|
15
|
+
import pytest
|
|
16
|
+
from pcetera import thermo
|
|
17
|
+
|
|
18
|
+
RTLN10 = thermo.R * 298.15 * thermo.LN10
|
|
19
|
+
N_DRAWS = 200 # Random energy sets per loop test
|
|
20
|
+
|
|
21
|
+
def _draw(rng):
|
|
22
|
+
"""Return random G for 5 states of one molecule & the 4 particles, plus an electrode potential (V)"""
|
|
23
|
+
offset = rng.uniform(-1e6, 0) # Up to ~1600 hartree (size of real total energies)
|
|
24
|
+
g = {s: offset + rng.uniform(-400, 400) for s in ("XH", "X-", "X.", "X+", "XH.+")}
|
|
25
|
+
p = {s: rng.uniform(-400, 400) for s in ("H+", "e-", "H.", "H-")}
|
|
26
|
+
return g, p, rng.uniform(-5, 5)
|
|
27
|
+
|
|
28
|
+
def _rand_h_ref(p, e_ref, rng):
|
|
29
|
+
"""Return a made-up H_REF entry matching the particles & electrode of a draw"""
|
|
30
|
+
c_g = p["H."] - p["H+"] - p["e-"] + thermo.F * e_ref
|
|
31
|
+
e_h2 = rng.uniform(-1, 1) # Any split of C_G into dGf(H.) & E(H+/H2)
|
|
32
|
+
return {"set": "made up", "solvent": "none", "ref": "none",
|
|
33
|
+
"dgf_h": c_g + thermo.F * e_h2, "e_h2": e_h2,
|
|
34
|
+
"dg_hminus": p["H-"] - p["H."] - p["e-"] + thermo.F * e_ref}
|
|
35
|
+
|
|
36
|
+
def _quantities(g, p, e_ref):
|
|
37
|
+
"""Return pKa, E(X./X-), BDFE & hydricity of XH"""
|
|
38
|
+
return (thermo.pka(g["XH"], g["X-"], p["H+"]),
|
|
39
|
+
thermo.potential(g["X-"], g["X."], p["e-"], e_ref, n=1),
|
|
40
|
+
thermo.bdfe(g["XH"], g["X."], p["H."]),
|
|
41
|
+
thermo.hydricity(g["XH"], g["X+"], p["H-"]))
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
### Derived constants against CODATA
|
|
45
|
+
def test_constants():
|
|
46
|
+
assert thermo.R * 4184 == pytest.approx(8.314462618, rel=1e-9) # J/(mol K)
|
|
47
|
+
assert thermo.F * 4184 == pytest.approx(96485.33212, rel=1e-9) # C/mol
|
|
48
|
+
assert thermo.HARTREE == pytest.approx(627.5094740631, rel=1e-10)
|
|
49
|
+
assert RTLN10 == pytest.approx(1.36425, abs=1e-5) # The "1.37" in most papers
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def test_to_kcal():
|
|
53
|
+
assert thermo.to_kcal(1.0, "hartree") == pytest.approx(627.5095, abs=1e-4)
|
|
54
|
+
assert thermo.to_kcal(4.184, "kJ/mol") == pytest.approx(1.0)
|
|
55
|
+
assert thermo.to_kcal(1.0, "eV") == pytest.approx(23.0605, abs=1e-4)
|
|
56
|
+
with pytest.raises(KeyError):
|
|
57
|
+
thermo.to_kcal(1.0, "kelvin")
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
### One RT ln10 of deprotonation free energy = one pKa unit, only differences matter
|
|
61
|
+
def test_pka():
|
|
62
|
+
assert thermo.pka(0.0, 10 * RTLN10, 0.0) == pytest.approx(10.0)
|
|
63
|
+
assert thermo.pka(-50.0, -50.0, 3 * RTLN10) == pytest.approx(3.0)
|
|
64
|
+
assert thermo.pka(0.0, RTLN10, 0.0, temp=350.0) == pytest.approx(298.15 / 350.0)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
### Sign, n, reference electrode, electron free energy
|
|
68
|
+
def test_potential():
|
|
69
|
+
F = thermo.F
|
|
70
|
+
assert thermo.potential(0.0, F, 0.0, e_abs_ref=0.0, n=1) == pytest.approx(1.0) # Red -> Ox costs F: +1 V
|
|
71
|
+
assert thermo.potential(0.0, F, 0.0, e_abs_ref=4.0, n=1) == pytest.approx(-3.0) # Same couple vs a reference at 4 V
|
|
72
|
+
assert thermo.potential(0.0, 2 * F, 0.0, e_abs_ref=0.0, n=2) == pytest.approx(1.0)
|
|
73
|
+
assert thermo.potential(0.0, F, -F, e_abs_ref=0.0, n=1) == pytest.approx(0.0) # G(e-) counts like any other particle
|
|
74
|
+
with pytest.raises(TypeError):
|
|
75
|
+
thermo.potential(0.0, 2 * F, 0.0, 0.0) # n has no default
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
### Check square scheme XH -> X- -> X. matches XH -> X. directly, for each random set
|
|
79
|
+
def test_square_scheme_closes():
|
|
80
|
+
rng = random.Random(1)
|
|
81
|
+
for _ in range(N_DRAWS):
|
|
82
|
+
g, p, e_ref = _draw(rng)
|
|
83
|
+
pka = thermo.pka(g["XH"], g["X-"], p["H+"])
|
|
84
|
+
e = thermo.potential(g["X-"], g["X."], p["e-"], e_ref, n=1) # E(X./X-)
|
|
85
|
+
c_g = p["H."] - p["H+"] - p["e-"] + thermo.F * e_ref # H+ + e- -> H. on this reference scale
|
|
86
|
+
|
|
87
|
+
path = RTLN10 * pka + thermo.F * e + c_g
|
|
88
|
+
assert path == pytest.approx(thermo.bdfe(g["XH"], g["X."], p["H."]), abs=1e-9)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
### Check hydricity cycle (lose H+, then 2 e-, then H+ + 2 e- -> H-) matches XH -> X+ + H- directly
|
|
92
|
+
def test_hydricity_cycle_closes():
|
|
93
|
+
rng = random.Random(2)
|
|
94
|
+
for _ in range(N_DRAWS):
|
|
95
|
+
g, p, e_ref = _draw(rng)
|
|
96
|
+
pka = thermo.pka(g["XH"], g["X-"], p["H+"])
|
|
97
|
+
e2 = thermo.potential(g["X-"], g["X+"], p["e-"], e_ref, n=2) # E(X+/X-), 2 electrons
|
|
98
|
+
h_minus = p["H-"] - p["H+"] - 2 * p["e-"] + 2 * thermo.F * e_ref # H+ + 2 e- -> H- on this reference scale
|
|
99
|
+
|
|
100
|
+
path = RTLN10 * pka + 2 * thermo.F * e2 + h_minus
|
|
101
|
+
assert path == pytest.approx(thermo.hydricity(g["XH"], g["X+"], p["H-"]), abs=1e-9)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
### Shift all states of one molecule by the same amount & check no result changes
|
|
105
|
+
def test_shift_all_states():
|
|
106
|
+
rng = random.Random(3)
|
|
107
|
+
for _ in range(N_DRAWS):
|
|
108
|
+
g, p, e_ref = _draw(rng)
|
|
109
|
+
shift = rng.uniform(-1000, 1000)
|
|
110
|
+
g_shift = {s: v + shift for s, v in g.items()}
|
|
111
|
+
assert _quantities(g_shift, p, e_ref) == pytest.approx(_quantities(g, p, e_ref), abs=1e-9)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
### Shift G(e-) by delta & electrode by delta/F -> same E for n = 1 & 2
|
|
115
|
+
### Shift only G(e-) -> E off by delta/F
|
|
116
|
+
def test_electron_convention():
|
|
117
|
+
rng = random.Random(4)
|
|
118
|
+
for _ in range(N_DRAWS):
|
|
119
|
+
g, p, e_ref = _draw(rng)
|
|
120
|
+
delta = rng.uniform(-5, 5)
|
|
121
|
+
for n, ox in [(1, "X."), (2, "X+")]:
|
|
122
|
+
e = thermo.potential(g["X-"], g[ox], p["e-"], e_ref, n=n)
|
|
123
|
+
both = thermo.potential(g["X-"], g[ox], p["e-"] + delta, e_ref + delta / thermo.F, n=n)
|
|
124
|
+
e_only = thermo.potential(g["X-"], g[ox], p["e-"] + delta, e_ref, n=n)
|
|
125
|
+
assert both == pytest.approx(e, abs=1e-9)
|
|
126
|
+
assert e_only == pytest.approx(e + delta / thermo.F, abs=1e-9)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
### Check functions taking h (eq 18, square scheme backwards, Scheme 8, oxidized hydride) vs straight from G
|
|
130
|
+
def test_h_ref_functions():
|
|
131
|
+
rng = random.Random(5)
|
|
132
|
+
for _ in range(N_DRAWS):
|
|
133
|
+
g, p, e_ref = _draw(rng)
|
|
134
|
+
h = _rand_h_ref(p, e_ref, rng)
|
|
135
|
+
pka = thermo.pka(g["XH"], g["X-"], p["H+"])
|
|
136
|
+
e_red = thermo.potential(g["X-"], g["X."], p["e-"], e_ref, n=1) # E(X./X-)
|
|
137
|
+
e_xplus = thermo.potential(g["X."], g["X+"], p["e-"], e_ref, n=1) # E(X+/X.)
|
|
138
|
+
e_xh = thermo.potential(g["XH"], g["XH.+"], p["e-"], e_ref, n=1) # E(XH.+/XH)
|
|
139
|
+
bdfe = thermo.bdfe(g["XH"], g["X."], p["H."])
|
|
140
|
+
hyd = thermo.hydricity(g["XH"], g["X+"], p["H-"])
|
|
141
|
+
|
|
142
|
+
assert thermo.bdfe_from_e_vs_h2(thermo.e_vs_h2_from_pka(pka, e_red, h), h) == pytest.approx(bdfe, abs=1e-9)
|
|
143
|
+
assert thermo.pka_from_bdfe(bdfe, e_red, h) == pytest.approx(pka, abs=1e-9)
|
|
144
|
+
assert thermo.hydricity_from_pka(pka, e_red, e_xplus, h) == pytest.approx(hyd, abs=1e-9)
|
|
145
|
+
assert thermo.bdfe_oxidized(hyd, e_xh, h) == pytest.approx(thermo.bdfe(g["XH.+"], g["X+"], p["H."]), abs=1e-9)
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
### Check a result keeps its value & set through copy & pickle
|
|
149
|
+
def test_copy_pickle():
|
|
150
|
+
w = thermo.get_h_ref("Wiedner 2016", "mecn", "Fc+/Fc")
|
|
151
|
+
e = thermo.e_vs_h2_from_pka(38.9, -2.03, w)
|
|
152
|
+
for e2 in [copy.copy(e), copy.deepcopy(e), copy.deepcopy({"e": e})["e"], pickle.loads(pickle.dumps(e))]:
|
|
153
|
+
assert e2 == e and e2.h_ref == ("Wiedner 2016", "mecn")
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
### Check an h w/o set & solvent (not from get_h_ref) still works, unmarked & unchecked
|
|
157
|
+
def test_h_without_set():
|
|
158
|
+
w = thermo.get_h_ref("Wiedner 2016", "mecn", "Fc+/Fc")
|
|
159
|
+
own = {k: w[k] for k in ("dgf_h", "e_h2", "dg_hminus")}
|
|
160
|
+
e = thermo.e_vs_h2_from_pka(38.9, -2.03, own)
|
|
161
|
+
assert e == thermo.e_vs_h2_from_pka(38.9, -2.03, w) and not isinstance(e, thermo.RefValue)
|
|
162
|
+
assert thermo.bdfe_from_e_vs_h2(thermo.e_vs_h2_from_pka(38.9, -2.03, w), own) == thermo.bdfe_from_e_vs_h2(e, w)
|
|
163
|
+
assert thermo.bdfe_oxidized(thermo.hydricity_from_pka(38.9, -2.03, -1.56, w), -1.16, own) == pytest.approx(50.7, abs=0.1)
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
### Check on_set takes an int, refuses a list (same for an array) & an h w/o set
|
|
167
|
+
def test_on_set_refuses():
|
|
168
|
+
w = thermo.get_h_ref("Wiedner 2016", "mecn", "Fc+/Fc")
|
|
169
|
+
v = thermo.on_set(60, w)
|
|
170
|
+
assert v == 60.0 and v.h_ref == ("Wiedner 2016", "mecn")
|
|
171
|
+
with pytest.raises(TypeError):
|
|
172
|
+
thermo.on_set([59.9, 69.8], w)
|
|
173
|
+
with pytest.raises(KeyError):
|
|
174
|
+
thermo.on_set(59.9, {k: w[k] for k in ("dgf_h", "e_h2", "dg_hminus")})
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Tests against Warren et al., Chem. Rev. 2010, 110, 6961 (superseded by Agarwal 2022)
|
|
4
|
+
|
|
5
|
+
C_G only, potentials vs NHE in water & Fc+/Fc otherwise
|
|
6
|
+
Printed BDFEs below follow eq 7, BDFE = 1.37 pKa + 23.06 E + C_G. The source rounded RT ln10 to 1.37,
|
|
7
|
+
not done here, which leaves 1.37 - RT ln10 = 0.0058 per pKa unit on top of the rounding
|
|
8
|
+
|
|
9
|
+
@author: Nathan Fong
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import pytest
|
|
13
|
+
from pcetera import thermo
|
|
14
|
+
|
|
15
|
+
RTLN10 = thermo.R * 298.15 * thermo.LN10
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Table 1: solvent, electrode, C_G
|
|
19
|
+
TABLE1 = [("water", "NHE", 57.6),
|
|
20
|
+
("mecn", "Fc+/Fc", 54.9),
|
|
21
|
+
("dmso", "Fc+/Fc", 71.1),
|
|
22
|
+
("dmf", "Fc+/Fc", 69.7), # No DMF or MeOH row below
|
|
23
|
+
("meoh", "Fc+/Fc", 65.3)]
|
|
24
|
+
|
|
25
|
+
### Check the stored C_G against Table 1 as printed (typo guard)
|
|
26
|
+
@pytest.mark.parametrize("solvent, ref, c_g", TABLE1)
|
|
27
|
+
def test_table1(solvent, ref, c_g):
|
|
28
|
+
assert thermo.c_g(thermo.get_h_ref("Warren 2010", solvent, ref)) == c_g
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Rows whose printed BDFE follows from their E & pKa: name, solvent, electrode, E, pKa, BDFE
|
|
32
|
+
ROWS = [("phenol", "water", "NHE", 0.79, 10.0, 89.5),
|
|
33
|
+
("FeII(H2bim)3", "mecn", "Fc+/Fc", -0.31, 17.5, 71.7),
|
|
34
|
+
("fluorene", "dmso", "Fc+/Fc", -1.069, 22.6, 77.4)]
|
|
35
|
+
|
|
36
|
+
### Check the printed BDFE, given this set w/ on_set, gives back the printed pKa
|
|
37
|
+
### Half a printed unit of BDFE plus 0.0058 per pKa unit, over RT ln10
|
|
38
|
+
@pytest.mark.parametrize("name, solvent, ref, e, pka, bdfe", ROWS)
|
|
39
|
+
def test_rows(name, solvent, ref, e, pka, bdfe):
|
|
40
|
+
h = thermo.get_h_ref("Warren 2010", solvent, ref)
|
|
41
|
+
tol = (0.05 + (1.37 - RTLN10) * pka) / RTLN10
|
|
42
|
+
assert thermo.pka_from_bdfe(thermo.on_set(bdfe, h), e, h) == pytest.approx(pka, abs=tol)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
### Check refusals: a 2010 BDFE w/ Agarwal 2022 values, E vs H2 or a BDFE from one on this set (no dGf(H.) or E(H+/H2)), water vs SHE
|
|
46
|
+
def test_refuses():
|
|
47
|
+
w = thermo.get_h_ref("Warren 2010", "water", "NHE")
|
|
48
|
+
with pytest.raises(ValueError, match="value from"):
|
|
49
|
+
thermo.pka_from_bdfe(thermo.on_set(89.5, w), 0.79, thermo.get_h_ref("Agarwal 2022", "water", "SHE")) # Phenol
|
|
50
|
+
with pytest.raises(KeyError):
|
|
51
|
+
thermo.e_vs_h2_from_pka(10.0, 0.79, w)
|
|
52
|
+
with pytest.raises(KeyError):
|
|
53
|
+
thermo.bdfe_from_e_vs_h2(1.38, w)
|
|
54
|
+
with pytest.raises(ValueError):
|
|
55
|
+
thermo.get_h_ref("Warren 2010", "water", "SHE") # Stored as printed, no conversion
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Tests against Wiedner et al., Chem. Rev. 2016, 116, 8655
|
|
4
|
+
|
|
5
|
+
MeCN, potentials vs Fc+/Fc, all on the Wiedner 2016 set (incl. its C_G of 53.6 for BDFEs)
|
|
6
|
+
Tolerance 0.1 kcal/mol & 0.1 pKa units (half a printed unit, plus half for rows built on a rounded result)
|
|
7
|
+
|
|
8
|
+
@author: Nathan Fong
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import pytest
|
|
12
|
+
from pcetera import thermo
|
|
13
|
+
|
|
14
|
+
W = thermo.get_h_ref("Wiedner 2016", "mecn", "Fc+/Fc")
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Check the Table 1 values that aren't stored (stored: 3.6, 103.6, 26.0)
|
|
18
|
+
def test_table1():
|
|
19
|
+
assert thermo.c_g(W) == pytest.approx(53.6, abs=1e-9) # H+ + e- -> H.
|
|
20
|
+
assert thermo.c_hyd(W) == pytest.approx(79.6, abs=1e-9) # H+ + 2e- -> H-
|
|
21
|
+
assert thermo.c_hyd(W) + 2 * thermo.F * W["e_h2"] == pytest.approx(76.0, abs=1e-9) # H2 -> H+ + H-
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Check [HPt(EtXantphos)2]+ & the PtIII hydride (Schemes 10 & 11)
|
|
25
|
+
def test_pt_hydride():
|
|
26
|
+
e_pt2_pt1, e_pt1_pt0, pka = -0.81, -0.97, 28.3
|
|
27
|
+
hyd = thermo.hydricity_from_pka(pka, e_pt1_pt0, e_pt2_pt1, W)
|
|
28
|
+
assert hyd == pytest.approx(77.2, abs=0.1)
|
|
29
|
+
assert thermo.bdfe_from_e_vs_h2(thermo.e_vs_h2_from_pka(pka, e_pt1_pt0, W), W) == pytest.approx(69.8, abs=0.1)
|
|
30
|
+
|
|
31
|
+
### PtIII hydride, E(HPtIII/HPtII) = +0.23
|
|
32
|
+
bdfe_pt3 = thermo.bdfe_oxidized(hyd, 0.23, W)
|
|
33
|
+
assert bdfe_pt3 == pytest.approx(45.9, abs=0.1)
|
|
34
|
+
assert thermo.pka_from_bdfe(bdfe_pt3, e_pt2_pt1, W) == pytest.approx(8.0, abs=0.1)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### Check HCo(dppe)2 & [HCo(dppe)2]+ (Scheme 15)
|
|
38
|
+
def test_co_hydride():
|
|
39
|
+
e_co1_co0, e_co0_com1, e_co2_co1, pka = -1.56, -2.03, -0.70, 38.9
|
|
40
|
+
hyd = thermo.hydricity_from_pka(pka, e_co0_com1, e_co1_co0, W)
|
|
41
|
+
assert hyd == pytest.approx(49.9, abs=0.1)
|
|
42
|
+
assert thermo.bdfe_from_e_vs_h2(thermo.e_vs_h2_from_pka(pka, e_co0_com1, W), W) == pytest.approx(59.9, abs=0.1)
|
|
43
|
+
|
|
44
|
+
### [HCo]+, E(HCoII/HCoI) = -1.16, loses H- to CoII
|
|
45
|
+
bdfe_co2 = thermo.bdfe_oxidized(hyd, -1.16, W)
|
|
46
|
+
pka_co2 = thermo.pka_from_bdfe(bdfe_co2, e_co1_co0, W)
|
|
47
|
+
assert bdfe_co2 == pytest.approx(50.7, abs=0.1)
|
|
48
|
+
assert pka_co2 == pytest.approx(24.2, abs=0.1)
|
|
49
|
+
assert thermo.hydricity_from_pka(pka_co2, e_co1_co0, e_co2_co1, W) == pytest.approx(60.5, abs=0.1)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
### Check results on this set are refused w/ Agarwal 2022 values (HCo(dppe)2 numbers)
|
|
53
|
+
def test_refused_by_agarwal():
|
|
54
|
+
a = thermo.get_h_ref("Agarwal 2022", "mecn", "Fc+/Fc")
|
|
55
|
+
e_co1_co0, e_co0_com1, pka = -1.56, -2.03, 38.9
|
|
56
|
+
e_vs_h2 = thermo.e_vs_h2_from_pka(pka, e_co0_com1, W)
|
|
57
|
+
hyd = thermo.hydricity_from_pka(pka, e_co0_com1, e_co1_co0, W)
|
|
58
|
+
with pytest.raises(ValueError, match="value from"):
|
|
59
|
+
thermo.bdfe_from_e_vs_h2(e_vs_h2, a)
|
|
60
|
+
with pytest.raises(ValueError, match="value from"):
|
|
61
|
+
thermo.pka_from_bdfe(thermo.bdfe_from_e_vs_h2(e_vs_h2, W), e_co0_com1, a)
|
|
62
|
+
with pytest.raises(ValueError, match="value from"):
|
|
63
|
+
thermo.pka_from_bdfe(thermo.bdfe_oxidized(hyd, -1.16, W), e_co1_co0, a)
|
|
64
|
+
with pytest.raises(ValueError, match="value from"):
|
|
65
|
+
thermo.bdfe_oxidized(hyd, -1.16, a)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
### Check the printed BDFE of HCo(dppe)2 (59.9, Scheme 15) given this set w/ on_set
|
|
69
|
+
def test_on_set():
|
|
70
|
+
a = thermo.get_h_ref("Agarwal 2022", "mecn", "Fc+/Fc")
|
|
71
|
+
bdfe = thermo.on_set(59.9, W)
|
|
72
|
+
assert thermo.pka_from_bdfe(bdfe, -2.03, W) == pytest.approx(38.9, abs=0.1)
|
|
73
|
+
with pytest.raises(ValueError, match="value from"):
|
|
74
|
+
thermo.pka_from_bdfe(bdfe, -2.03, a)
|
|
75
|
+
with pytest.raises(ValueError, match="value from"):
|
|
76
|
+
thermo.on_set(bdfe, a)
|