Skip to content

Add reaction free energy and reduction potential helpers - #79

Merged
galjos merged 2 commits into
mainfrom
redox-thermochemistry
Jul 6, 2026
Merged

Add reaction free energy and reduction potential helpers#79
galjos merged 2 commits into
mainfrom
redox-thermochemistry

Conversation

@galjos

@galjos galjos commented Jul 6, 2026

Copy link
Copy Markdown
Member

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 a Thermo (coefficient 1) or a (coefficient, Thermo) tuple; output in H / 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. Pass reference_potential=0.0 for 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

  • CI-safe exact-math tests: unit conversions, stoichiometry tuples, unknown-unit ValueError, absolute + vs-SHE potentials, n_electrons, public API export.
  • A skippable native-xtb benzoquinone reduction end-to-end test (gated on xtb / 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.

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

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.85%. Comparing base (f725da9) to head (47b117d).

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              
Flag Coverage Δ
unittests 96.85% <100.00%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.
@galjos
galjos merged commit 89dd177 into main Jul 6, 2026
4 checks passed
@galjos
galjos deleted the redox-thermochemistry branch July 6, 2026 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant