Redox potentials and pKa
This page documents the first implementation of the v2.x electrochemistry workflow: solution pKa values and redox potentials from an explicit pair of molecular states. It is a thermodynamic-cycle wrapper, not a new electronic structure engine. The quantum energy comes from an existing closed-shell SCF and the solvent term comes from the existing ALPB model.
Status. Implemented and exposed on the Rust, Python, WASM and CLI surfaces. It remains alpha: the validation set is small and the absolute values carry the systematic error of UHF/STO-3G.
Feature.
alpha-redox-pka(included inalpha-v2).
Why an explicit pair
Automatic protonation-site enumeration and automatic redox-state assignment are separate cheminformatics problems. This API asks the caller for the two states:
| Workflow | State 1 | State 2 |
|---|---|---|
| pKa | acid HA | conjugate base A- |
| Redox | oxidised Ox | reduced Red |
That keeps the electronic-structure input unambiguous: the formal charge is read from the SMILES ([O-], [NH4+], …), and the geometry is embedded independently for each state.
pKa cycle
For a deprotonation
the absolute cycle is
G(H+) is the proton solvation free energy. Its absolute value depends on the standard state and on the solvent, so the result always reports the value used. The default is -265.9 kcal/mol for water.
Relative pKa is the recommended path
Absolute pKa inherits the systematic error of the electronic method and the proton convention. The relative cycle against a reference acid cancels most of that error:
PkaReference::acetic_acid() supplies the reference pair and pKa = 4.76. Supplying the target as its own reference reproduces the reference value exactly, which is the unit-test invariant of the implementation. Adding ΔpKa to the reference shifts the result by exactly ΔpKa; for the trifluoroacetic-acid/acetic-acid pair the measured relative value is 0.821273767634362 (experimental 0.23).
flowchart LR
A["target<br/>HA → A⁻"] --> C["ΔG_target"]
B["reference<br/>HA_ref → A⁻_ref<br/>pKa_ref"] --> D["ΔG_ref"]
C --> E["pKa = pKa_ref + (ΔG_target − ΔG_ref)/(RT ln 10)"]
D --> E
E --> F["PkaResult<br/>relative=true + reference summary"]
Validation: empty or whitespace target/reference SMILES raise ValueError (WASM {"error": ...}); reference_pka must be finite; n_conformers >= 1; the method must be uhf/hf or xtb/gfn2. The xTB backend only accepts neutral closed-shell states. Non-finite conformer energies, ALPB terms, charges, coordinates or summaries are numerical errors, not returned as NaN.
The absolute path is much weaker than the relative one. With the default UHF/STO-3G backend, acetic acid gives
pKa(absolute) = 116.88090049031462
ΔG_dep = 159.4544193232432 kcal/mol
G(HA) = -141051.76704042466 kcal/mol
G(A-) = -140626.41262110142 kcal/molThe gas-phase part alone is 478.75 kcal/mol, versus roughly 348 kcal/mol experimentally. That ~130 kcal/mol minimal-basis error survives the proton correction and dominates the cycle, so the absolute number is not a quantitative pKa. The relative TFA/acetic-acid cycle, where the error largely cancels, gives 0.821273767634362 (experimental 0.23; see the validation table). Use the relative path for comparisons and treat absolute values as a qualitative diagnostic only.
Redox cycle
For the reduction
the reaction free energy is
with the electron free energy set to zero by convention. The absolute potential and the potential against a reference electrode are
The default reference is the standard hydrogen electrode at 4.44 V. A relative cycle against a couple with a known experimental potential is also available:
The absolute redox scale inherits the same minimal-basis error as the pKa cycle. The test fixture CC(=O)O/CC(=O)[O-] is not a real redox couple; it only checks the sign and unit conversion and returns E_abs = -18.445112550288258 V, E_SHE = -22.88511255028826 V. Do not read those numbers as chemistry. Supply an actual oxidised/reduced pair and prefer a relative cycle against a measured couple.
The self-reference invariant is exact: target == reference returns potential_vs_reference_v == reference_potential_v. A reference potential of 0.5 V therefore returns 0.5 V for the same couple. n_electrons must be an integer in 1..=4; a reference with a different electron count is rejected. Both reference SMILES must be non-empty and the reference potential finite. RedoxResult.reference carries the reference potential, ΔG and state energies.
flowchart LR
A["target<br/>Ox + n e⁻ → Red"] --> C["ΔG_target"]
B["reference couple<br/>Ox_ref + n e⁻ → Red_ref<br/>E_ref"] --> D["ΔG_ref"]
C --> E["E = E_ref − (ΔG_target − ΔG_ref)/(nF)"]
D --> E
E --> F["RedoxResult<br/>relative=true + reference summary"]
Method
For each state:
- Parse the SMILES and read the total formal charge.
- Embed a conformer ensemble with the existing ETKDG pipeline.
- Evaluate each conformer with closed-shell UHF/STO-3G.
- Evaluate ALPB solvation with the SCF Mulliken charges.
- Add the electronic and solvation energies.
- Select the minimum or the Boltzmann average at the configured temperature.
The default electronic method is UHF/STO-3G because the current GFN2-xTB path is neutral-only. The Xtb backend is available for neutral states and is faster; it returns Unsupported for a charged state instead of silently using the wrong electron count.
API
Rust
use sci_form::electrochemistry::{
ElectrochemistryConfig, PkaReference, RedoxReference,
};
use sci_form::{compute_pka, compute_redox_potential};
let reference = PkaReference::acetic_acid();
let config = ElectrochemistryConfig::default();
let result = compute_pka(
"FC(F)(F)C(=O)O",
"FC(F)(F)C(=O)[O-]",
Some(&reference),
&config,
)?;
println!("pKa = {:.2}", result.pka);
println!("ΔG = {:.2} kcal/mol", result.delta_g_kcal_mol);
println!("conformer spread = {:.2} kcal/mol", result.acid.spread_kcal_mol);A redox call has the same shape:
let result = compute_redox_potential(
oxidized_smiles,
reduced_smiles,
/* n_electrons = */ 1,
Some(&reference_couple),
&config,
)?;Python, WASM and CLI
The same workflow is exposed on every surface:
| Surface | Entry points |
|---|---|
| Python | compute_pka (reference via reference_acid/reference_base/reference_pka), compute_redox_potential (reference via reference_oxidized/reference_reduced/reference_potential), PkaResult, PkaReferenceResult, RedoxResult, RedoxReferenceResult |
| WASM | compute_pka, compute_pka_relative, compute_redox_potential, compute_redox_potential_relative |
| CLI | sci-form pka ..., sci-form redox ... |
Python example:
import sci_form
result = sci_form.compute_pka(
"FC(F)(F)C(=O)O",
"FC(F)(F)C(=O)[O-]",
reference_acid="CC(=O)O",
reference_base="CC(=O)[O-]",
reference_pka=4.76,
)
print(result.pka, result.relative)
print(result.reference.pka, result.reference.delta_g_kcal_mol)WASM takes the reference explicitly:
const result = JSON.parse(
compute_pka_relative(
'FC(F)(F)C(=O)O', 'FC(F)(F)C(=O)[O-]',
'CC(=O)O', 'CC(=O)[O-]',
4.76, 'uhf',
),
);
// result.pka == 0.821273767634362
// result.reference = { acid_smiles, base_smiles, pka, acid, base, delta_g_kcal_mol }
const redox = JSON.parse(
compute_redox_potential_relative(
oxidized, reduced, 1,
reference_oxidized, reference_reduced, 0.0, 'uhf',
),
);
// same couple as reference: redox.potential_vs_reference_v == 0.0CLI example:
sci-form pka "CC(=O)O" "CC(=O)[O-]" \
--reference-acid "CC(=O)O" --reference-base "CC(=O)[O-]" \
--reference-pka 4.76 --n-conformers 1The CLI prints the full JSON result, including every conformer and note. The Python classes expose the top-level fields; the WASM functions return the full JSON payload. All three reference options must be supplied together; the same rule applies to the redox reference couple. --n-electrons is limited to 1–4 and --n-conformers must be ≥ 1. The CLI accepts uhf and xtb, plus pbe0 when built with alpha-dft-hybrid; Python and WASM expose uhf/xtb (xtb rejects charged states rather than changing the electron count).
Result fields
| Type | Key fields |
|---|---|
StateEnergy | charge, selected_kcal_mol, boltzmann_kcal_mol, spread_kcal_mol, conformers |
PkaResult | pka, delta_g_kcal_mol, relative, reference, notes |
RedoxResult | potential_vs_reference_v, absolute_potential_v, delta_g_kcal_mol, relative, reference, notes |
Energies are in kcal/mol, potentials in volt, temperature in kelvin and pKa is dimensionless.
Units and conventions
| Quantity | Unit / convention |
|---|---|
| Electronic energy | kcal/mol after conversion from Hartree |
| Solvation energy | kcal/mol |
| Proton solvation | kcal/mol, default -265.9 |
| Reference electrode | V, default SHE at 4.44 V |
| Temperature | K, default 298.15 |
| pKa | dimensionless |
| Molar gas constant | 0.001987204258 kcal/(mol·K) |
| Faraday constant | 23.060548867 kcal/(mol·V) |
Every result carries the conventions it used. A change in the proton solvation term or the reference electrode is visible in the output, not hidden in a constant.
Validation
The current gates are:
| Gate | Observable | Result |
|---|---|---|
| Formula | Acetic-acid-scale ΔG → pKa | 4.76 ± 0.05 |
| Self-reference | Target = reference acid | exact reference pKa |
| Charge parsing | [O-], [NH4+], neutral | -1, +1, 0 |
| Redox formula | ΔG = -23.06 kcal/mol, n = 1 | E_abs = 1 V |
| TFA trend | Relative to acetic acid | pKa 0.82 (experimental 0.23) |
| Absolute pKa | Acetic acid, UHF/STO-3G | 116.88 (not quantitative) |
| Absolute redox | Formula fixture, UHF/STO-3G | -18.445 V (not chemistry) |
| Input validation | NaN reference, n_conformers=0, n_electrons=0, charged xTB, bad SMILES | ValueError / {error} before or during the call |
| Solvent config | Negative/non-finite surface tension | rejected before SCF |
| Heavy integration | TFA + reference, UHF/STO-3G | ignored by default; run with --ignored |
The TFA value shows the expected trend and the size of the systematic error. It is not a claim of 0.5 pKa accuracy. The absolute acetic-acid value is included so the failure mode is visible: the minimal basis misses the gas-phase deprotonation energy by about 130 kcal/mol. A production validation set with experimental acids, bases and redox couples is still required before promotion.
Limitations
- UHF/STO-3G is a minimal-basis, uncorrelated method. Absolute pKa and redox values are not quantitative (acetic acid: 116.88 versus 4.76); only the relative cycle is usable for comparisons.
- Reference
pKa, reference potential and the solvent surface tension must be finite; a finite reference pKa is checked before any SCF work.n_conformersmust be at least 1 andn_electronsmust be 1–4. - Malformed SMILES, invalid arguments and unsupported backend/state combinations are
ValueErrorin Python and{"error": ...}in WASM; SCF/embedding failures remainRuntimeError/NotConvergedError. - Thermal and vibrational corrections are not included. The result is an electronic-plus-solvation free energy, not a full RRHO free energy.
- The workflow requires a closed-shell, even-electron state.
- GFN2-xTB is neutral-only in the current core. Charged states use UHF.
- Conformer sampling is the existing ETKDG ensemble; a single conformer is the default for speed and can miss a lower state.
- The caller must supply the correct conjugate base or redox pair. The API does not enumerate protonation or oxidation states.
- The relative result is only as good as the reference value and the similarity between target and reference.
Next steps
- Add a curated acid/base/redox benchmark with experimental references.
- Add thermal corrections from the existing vibrational analysis.
- Investigate charged GFN2-xTB support so the fast backend can replace UHF for the production path.
- Add the validation rows to the full matrix and the scientific report.