Add reaction free energy and reduction potential helpers - #79
Merged
Conversation
Introduce ThermoScreening.thermo.reactions with two pure post-processing helpers that combine per-species absolute Gibbs free energies (Thermo.total_EeGtot) computed by any engine: - reaction_free_energy(reactants, products, unit): dG = sum(products) - sum(reactants), with (coefficient, Thermo) stoichiometry tuples and H / eV / kcal / kJ output units. - reduction_potential(oxidized, reduced, n_electrons, reference_potential): E = -dG_red / n, referenced to the SHE by default (override for a calibrated reference or 0.0 for the absolute potential). Both are exported from ThermoScreening.thermo. Adds CI-safe exact-math tests plus a skippable native-xtb benzoquinone end-to-end test, and docs (API reference + a usage section) with a prominent caveat that GFN-xTB/DFTB absolute redox potentials are quantitatively poor and best used for relative trends or with a calibrated reference.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #79 +/- ##
==========================================
+ Coverage 96.80% 96.85% +0.05%
==========================================
Files 25 26 +1
Lines 1629 1655 +26
==========================================
+ Hits 1577 1603 +26
Misses 52 52
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Address review feedback: raise ValueError for n_electrons == 0 rather than an opaque ZeroDivisionError, add a kJ/mol unit assertion, and derive the kcal factor from PhysicalConstants['cal'] for codebase consistency.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
ThermoScreening.thermo.reactions, two pure post-processing helpers that combine per-species absolute Gibbs free energies (Thermo.total_EeGtot(), electronic + thermal) into reaction thermochemistry. Compute each species with any engine (dftbplus_thermo/xtb_thermo/xtb_cli_thermo) under matched conditions, then combine:reaction_free_energy(reactants, products, unit="kcal")— ΔG = Σ(products) − Σ(reactants). Species entries are aThermo(coefficient 1) or a(coefficient, Thermo)tuple; output inH/eV/kcal/kJ.reduction_potential(oxidized, reduced, n_electrons=1, reference_potential=SHE_ABSOLUTE_POTENTIAL)—E = -ΔG_red / n(electron free energy taken as zero), referenced to the SHE (4.44 V, IUPAC) by default. Passreference_potential=0.0for the absolute potential.Both are exported from
ThermoScreening.thermo.This directly serves charged / open-shell / solvated workflows (radical anions in solution) enabled by the native-xtb backend.
Tests
ValueError, absolute + vs-SHE potentials,n_electrons, public API export.xtbbenzoquinone reduction end-to-end test (gated onxtb/XTB_COMMAND) that checks the pipeline runs and the reduction is favorable — not experimental accuracy.Docs
API reference entries plus a "Reactions and redox" usage section with a worked example and a prominent
.. warning::that GFN-xTB / DFTB absolute redox potentials are quantitatively poor (benzoquinone GFN2 EA ~7 eV vs ~1.9 eV experimental) and are best used for relative trends or with a calibrated reference.