Skip to content

Analytical Models (softpotato.analytical)

The softpotato.analytical package provides closed-form solutions, asymptotic expansions, and empirical electrochemical models for rapid baseline calculations and solver benchmarking.

Consistent Units

All functions in softpotato.analytical are unit-agnostic as long as length units are consistent across D, area, c_bulk, nu, and electrode radius a (for example, all SI: \(\text{m}\), \(\text{m}^2\), \(\text{mol}/\text{m}^3\); or all CGS: \(\text{cm}\), \(\text{cm}^2\), \(\text{mol}/\text{cm}^3\)).

Submodules Overview

softpotato.analytical.step — Potential & Current Steps

  • cottrell, cottrell_spherical, cottrell_cylinder, cottrell_step: Chronoamperometric current transients at planar, spherical, and cylindrical electrodes.
  • anson: Chronocoulometric charge \(Q(t)\) for planar potential steps.
  • sand, sand_transition_time, sand_potential: Galvanostatic chronopotentiometry transition time \(\tau\) and \(E(t)\) response.
  • step_concentration_profile, step_flux_profile: Exact error-function spatial concentration \(c(x, t)\) and interfacial flux profiles.

softpotato.analytical.hydrodynamics — RDE & RRDE

  • levich, levich_constant, nernst_diffusion_layer: Levich limiting current \(I_L\), Levich constant \(B\), and Nernst diffusion layer thickness \(\delta_N\).
  • koutecky_levich, koutecky_levich_analysis: Mixed kinetic/mass-transport RDE current and regression.
  • rpm_to_rad_s, rad_s_to_rpm: Angular velocity conversions (\(\omega = 2\pi \cdot \text{rpm} / 60\)).
  • collection_efficiency, ring_limiting_current, ring_collection_current, shielding_factor, rotating_ring_disk: Albery–Bruckenstein rotating ring-disk electrode (RRDE) equations.

softpotato.analytical.kinetics — Interfacial Kinetics

  • nernst, nernst_potential, nernst_ratio, nernst_equilibrium_concentrations: Equilibrium potential and surface concentration ratios.
  • exchange_current, exchange_current_density, charge_transfer_resistance: \(I_0\), \(j_0\), and \(R_{\text{ct}}\).
  • butler_volmer, butler_volmer_current_density, butler_volmer_linear: Full and low-overpotential linearized Butler–Volmer equations.
  • tafel, tafel_slope, tafel_overpotential, tafel_analysis: High-field Tafel kinetics.

softpotato.analytical.voltammetry — Voltammetric Diagnostics

  • randles_sevcik, randles_sevcik_irreversible, randles_sevcik_quasi: Reversible, irreversible, and quasi-reversible CV peak currents.
  • nicholson_psi, nicholson_delta_ep, nicholson_rate_constant: Nicholson working curve relating \(\Delta E_p\) to \(\Psi\) and \(k^0\).
  • matsuda_ayabe, matsuda_ayabe_lambda, peak_potential_irreversible: Dimensionless reversibility parameter \(\Lambda\) and regime classification.

softpotato.analytical.microelectrodes — Ultramicroelectrodes (UMEs)

  • microdisc_limiting_current, microhemisphere_limiting_current, microsphere_limiting_current, microband_limiting_current: Steady-state UME limiting currents.
  • microdisc_transient, mahon_oldham_transient: Shoup–Szabo and Mahon–Oldham microdisc chronoamperometric transients.

softpotato.analytical.secm — Scanning Electrochemical Microscopy

  • secm_approach_positive_feedback, secm_approach_negative_feedback, secm_approach_curve: Normalized SECM tip current \(I_T(L)\) for conducting, insulating, and finite-kinetics substrates.
  • secm_limiting_current_infinite, secm_tip_current: Steady-state tip current in bulk and dimensional approach currents.

Full Runnable Script

"""User Guide: Analytical Models across softpotato.analytical Submodules.

Demonstrates closed-form equations in:
1. step: cottrell, anson, sand_transition_time
2. hydrodynamics: levich, koutecky_levich, collection_efficiency
3. kinetics: nernst, butler_volmer, tafel_slope
4. voltammetry: randles_sevcik, nicholson_psi, matsuda_ayabe
5. microelectrodes: microdisc_limiting_current, microdisc_transient
6. secm: secm_approach_positive_feedback, secm_approach_negative_feedback, secm_approach_curve
"""

import numpy as np

from softpotato.analytical import (
    hydrodynamics,
    kinetics,
    microelectrodes,
    secm,
    step,
    voltammetry,
)

# Consistent SI units
n = 1
D = 1.0e-9  # m^2/s
c_bulk = 1.0  # mol/m^3 (= 1 mM)
area = 7.07e-6  # m^2 (3 mm disk)
nu = 1.0e-6  # m^2/s (water)
T = 298.15  # K

# 1. Step techniques
t = np.array([0.1, 0.5, 1.0, 2.0])
i_cott = step.cottrell(t, n=n, D=D, c_bulk=c_bulk, area=area)
q_anson = step.anson(t, n=n, D=D, c_bulk=c_bulk, area=area)
tau_sand = step.sand_transition_time(I=4.0e-5, n=n, D=D, c_bulk=c_bulk, area=area)
print(
    f"Step: Cottrell I(1s) = {i_cott[2] * 1e6:.2f} uA, "
    f"Anson Q(1s) = {q_anson[2] * 1e6:.2f} uC, Sand tau = {tau_sand:.3f} s"
)

# 2. Hydrodynamics (RDE & RRDE)
i_lev = hydrodynamics.levich(rpm=1600, n=n, D=D, c_bulk=c_bulk, area=area, nu=nu)
i_kl = hydrodynamics.koutecky_levich(
    omega=hydrodynamics.rpm_to_rad_s(1600),
    n=n,
    D=D,
    c_bulk=c_bulk,
    area=area,
    nu=nu,
    i_k=5.0e-4,
)
n_coll = hydrodynamics.collection_efficiency(r1=2.5e-3, r2=2.75e-3, r3=3.75e-3)
print(
    f"Hydrodynamics: I_L(1600 rpm) = {i_lev * 1e6:.2f} uA, "
    f"I_KL = {i_kl * 1e6:.2f} uA, RRDE N = {n_coll:.3f}"
)

# 3. Interfacial Kinetics
e_eq = kinetics.nernst(E0=0.0, n=n, c_ox=1.0, c_red=0.1, T=T)
i_bv = kinetics.butler_volmer(eta=-0.1, i0=1.0e-5, alpha=0.5, n=n, T=T)
b_tafel = kinetics.tafel_slope(alpha=0.5, n=n, T=T)
print(
    f"Kinetics: E_eq = {e_eq:.4f} V, I_BV(-0.1 V) = {i_bv * 1e6:.2f} uA, "
    f"Tafel slope = {b_tafel * 1e3:.1f} mV/dec"
)

# 4. Voltammetry
i_rs = voltammetry.randles_sevcik(v=0.1, c_bulk=c_bulk, D=D, area=area, n=n, T=T)
nich = voltammetry.nicholson_psi(delta_ep=0.085, v=0.1, D=D, n=n, T=T, in_volts=True)
ma = voltammetry.matsuda_ayabe(k0=nich.k0, v=0.1, D=D, n=n, alpha=0.5, T=T)
print(
    f"Voltammetry: I_p = {i_rs * 1e6:.2f} uA, "
    f"Nicholson k0 = {nich.k0:.2e} m/s ({ma.classification})"
)

# 5. Microelectrodes (UME)
a_ume = 12.5e-6  # 25 um diameter disk
i_ss = microelectrodes.microdisc_limiting_current(radius=a_ume, n=n, D=D, c_bulk=c_bulk)
i_tr = microelectrodes.microdisc_transient(
    t=0.01, radius=a_ume, n=n, D=D, c_bulk=c_bulk
)
print(
    f"Microelectrodes: I_ss = {i_ss * 1e9:.2f} nA, "
    f"I_transient(10 ms) = {i_tr * 1e9:.2f} nA"
)

# 6. SECM Approach Curves
L = np.array([0.2, 0.5, 1.0, 2.0])
it_pos = secm.secm_approach_positive_feedback(L, RG=5.0)
it_neg = secm.secm_approach_negative_feedback(L, RG=5.0)
it_kin = secm.secm_approach_curve(L, RG=5.0, kappa=2.0)
print(
    f"SECM (L=0.5): I_T(+) = {it_pos[1]:.3f}, "
    f"I_T(kappa=2) = {it_kin[1]:.3f}, I_T(-) = {it_neg[1]:.3f}"
)