Techniques Module (softpotato.techniques)¶
The softpotato.techniques subpackage provides high-level electrochemical experimental protocols, excitation waveform generators, an automated simulation pipeline (simulate, simulate_sweep), a structured result container (TechniqueResult), a declarative Matplotlib plotting suite, and automated electrochemical diagnostics.
Theoretical Background¶
1. Potentiostatic vs. Galvanostatic Excitation & Event-Aware Integration¶
Every experimental technique in softpotato.techniques subclasses BaseTechnique, encapsulating a time-dependent excitation signal over \(t \in [0, t_{\max}]\) under either:
- Potentiostatic control (
mode="potentiostatic"): prescribes the electrode potential \(E(t)\) at the working electrode boundary, driving interfacial Nernstian, Butler–Volmer, or Tafel charge transfer. - Galvanostatic control (
mode="galvanostatic"): prescribes the net Faradaic current \(I(t)\) (e.g.Chronopotentiometry), enforcing a Neumann interfacial flux \(J(t) = I(t) / (n F A)\) and recovering the electrode potential \(E(t)\) from the resulting surface concentrations.
Techniques with sharp step edges or switching vertices (CA, CV, DPV, SWV, SCV, CP, CustomWaveform) expose exact interior timestamps via event_times. simulate performs piecewise event-aware integration across each smooth sub-interval, preventing adaptive ODE solvers (Radau, BDF) from stepping over narrow pulses or switching vertices.
2. Sampled-Current Voltammetry (SCV)¶
SampledCurrentVoltammetry models a family of \(K\) independent constant-potential step experiments \(\{E_1, E_2, \dots, E_K\}\), each held for identical duration \(t_{\max}\) (with optional common quiet time \(t_{\text{quiet}}\) at \(E_{\text{quiet}}\)). Sampling the resulting chronoamperometric transients \(I_k(t)\) at one or more fixed sampling times \(\tau \in (0, t_{\max}]\) yields a sampled-current voltammogram \(I(\tau)\) vs. \(E_k\) free of charging-current interference at sufficiently long \(\tau\):
3. Pulse Voltammetry (DPV & SWV)¶
- Differential Pulse Voltammetry (
DifferentialPulseVoltammetry): superimposes a constant-amplitude pulse \(\Delta E_p\) onto a staircase ramp of step height \(\Delta E_s\) and period \(t_{\text{period}}\). Current is sampled just before pulse application (\(I_{\text{pre}}\)) and at the end of the pulse (\(I_{\text{pulse}}\)), yielding the differential peak-shaped signal \(\Delta I = I_{\text{pulse}} - I_{\text{pre}}\) vs. \(E_{\text{base}}\). - Square Wave Voltammetry (
SquareWaveVoltammetry): applies a symmetric square wave of amplitude \(E_{\text{sw}}\) and frequency \(f\) (\(T = 1/f\)) superimposed on a staircase ramp \(\Delta E_s\). Sampling at the end of each forward and reverse half-cycle produces \(I_{\text{forward}}\), \(I_{\text{reverse}}\), and the net signal \(I_{\text{net}} = I_{\text{forward}} - I_{\text{reverse}}\).
4. Rotating Disk Electrode (RDE) Hydrodynamics¶
RotatingDiskElectrode couples any potentiostatic waveform with convective-diffusion mass transport at angular velocity \(\omega\) (\(\text{rad}\,\text{s}^{-1}\)) or rotational speed \(\text{rpm}\) in an electrolyte of kinematic viscosity \(\nu\):
"nernst_layer": truncates the spatial domain at the steady-state Nernst diffusion layer thickness \(\delta_N = 1.61\, D^{1/3} \omega^{-1/2} \nu^{1/6}\) with bulk Dirichlet conditions at \(x = \delta_N\)."levich_convection": solves the full 1D convective-diffusion PDE \(\partial c_i / \partial t = D_i \partial^2 c_i / \partial x^2 - v_x(x) \partial c_i / \partial x + R_i\) using the Cochran axial velocity profile \(v_x(x) = -0.510\, \omega^{3/2} \nu^{-1/2} x^2\) viaRDEConvectionTerm.
API Overview¶
Waveforms & Experimental Techniques¶
| Class | Mode | Key Parameters | Description |
|---|---|---|---|
BaseTechnique |
Both | mode, duration, event_times, plot_specs |
Abstract base class for all electrochemical excitation protocols. |
Chronoamperometry |
Potentiostatic | E_step, duration, E_step1/E_step2, potentials/durations, E_quiet, t_quiet |
Single-, double-, and multi-step potential chronoamperometry. |
LinearSweepVoltammetry |
Potentiostatic | E_start, E_end, scan_rate, dE, n_points |
Unidirectional linear potential sweep \(E(t) = E_{\text{start}} \pm v t\). |
CyclicVoltammetry |
Potentiostatic | E_start, E_vertex1, E_vertex2, scan_rate, E_end, n_cycles |
Single- or multi-cycle triangular potential waveform with switching vertices. |
SampledCurrentVoltammetry |
Potentiostatic | potentials or (E_start, E_end, dE/step_height), duration, sample_times |
Family of independent constant-potential steps sampled at fixed \(\tau\). |
DifferentialPulseVoltammetry |
Potentiostatic | E_start, E_end, step_height, pulse_amplitude, pulse_width, pulse_period, sample_fraction |
Staircase + pulse waveform with sample_currents returning (E_base, i_pre, i_pulse, i_diff). |
SquareWaveVoltammetry |
Potentiostatic | E_start, E_end, step_height, amplitude, frequency, sample_fraction |
Staircase + square-wave waveform with sample_currents returning (E_step, i_forward, i_reverse, i_net). |
Chronopotentiometry |
Galvanostatic | current, duration, currents/durations, I_quiet, t_quiet |
Single- or multi-step constant-current protocol with potential recovery and transition time \(\tau\) detection. |
RotatingDiskElectrode |
Potentiostatic | waveform, omega/rpm, kinematic_viscosity, model |
Hydrodynamic RDE wrapper ('nernst_layer' or 'levich_convection'). |
RDESweep / simulate_rde_sweep |
Potentiostatic | omegas/rpms, waveform or (E_start, E_end, scan_rate), model |
Multi-rotation-rate RDE sweep builder and runner returning RDESweepResult. |
CustomWaveform |
Both | segments, mode, n_points |
Composite excitation chaining ConstantSegment, LinearRampSegment, SinusoidalSegment, and CallableSegment. |
Simulation Pipeline & Result Container¶
| Symbol | Key Parameters / Attributes | Description |
|---|---|---|
simulate |
technique, mechanism, geometry, grid, solver, t_eval, kinetics |
End-to-end simulation orchestrator: builds physics-informed mesh, assembles BCs, integrates piecewise across event_times, and returns TechniqueResult. |
simulate_sweep |
techniques, mechanism, values, geometry, solver |
Runs parameter sweeps (sequence, mapping, or factory callable + values) via simulate. |
TechniqueResult |
time, potential, current, charge, solver_result, cycles, E_step/i_net, E_base/i_diff, transition_time, sample_currents(), plot(), plot_summary() |
Structured result container with dict-like species access (result["Ox"]), technique-specific views, and plotting facade. |
Declarative Plotting Interfaces¶
Every plotting function accepts an optional Matplotlib ax, returns (fig, ax) (or (fig, axes) for plot_summary), uses SI units and IUPAC current polarity (anodic positive, cathodic negative), and never calls plt.show().
| Function / Helper | Plot Kind Key | Description |
|---|---|---|
PlotSpec / resolve_plot_kind |
PLOT_ALIASES |
Declarative plot metadata and alias resolver mapping verbose names (e.g. 'current_vs_time') to canonical keys ('i_vs_t'). |
plot_result |
kind=None (uses result.default_plot) |
Central technique-aware dispatcher (also exposed as result.plot(kind=...)). |
plot_summary |
Multi-panel (1x3 or 2x2) |
Renders default technique plot alongside 'i_vs_t', 'E_vs_t', and 'c_vs_x' (also result.plot_summary()). |
plot_sweep |
Any supported kind |
Overlays Sequence[TechniqueResult], Mapping[Any, TechniqueResult], or RDESweepResult on a single axes. |
plot_voltammogram |
'voltammogram' |
\(I\) vs. \(E\) voltammogram with optional CV cycle selection and peaks overlay. |
plot_current_vs_time |
'i_vs_t' |
\(I(t)\) chronoamperogram (supports 2D SampledCurrentVoltammetry step families via step=). |
plot_potential_vs_time |
'E_vs_t' |
\(E(t)\) waveform or chronopotentiogram with optional transition-time \(\tau\) marker. |
plot_concentration_profile |
'c_vs_x' |
Spatial concentration profile \(c_i(x, t)\) at one or more timestamps t and species. |
plot_charge_vs_time |
'Q_vs_t' |
Cumulative charge \(Q(t)\) chronocoulogram. |
plot_scv |
'scv' |
Sampled-current voltammogram \(I(\tau)\) vs. \(E_{\text{step}}\) for one or more sample_times. |
plot_dpv |
'dpv' |
Differential pulse voltammogram (\(\Delta I\) and optional i_pre, i_pulse components). |
plot_swv |
'swv' |
Square-wave voltammogram (\(I_{\text{net}}\) and optional i_forward, i_reverse components). |
plot_peaks |
Diagnostic | Voltammogram with detected anodic/cathodic peak markers and annotations. |
plot_randles_sevcik |
Diagnostic | \(I_p\) vs. \(v^{1/2}\) Randles–Ševčík regression and fitted line. |
plot_cottrell |
Diagnostic | \(I\) vs. \(t^{-1/2}\) Cottrell regression and fitted line. |
plot_levich |
Diagnostic | \(I_L\) vs. \(\omega^{1/2}\) Levich regression and fitted line. |
plot_koutecky_levich |
Diagnostic | \(1/I\) vs. \(\omega^{-1/2}\) Koutecký–Levich regression and fitted line. |
plot_tafel |
Diagnostic | $\log_{10} |
Post-Processing & Diagnostics¶
| Function / Dataclass | Inputs | Output | Description |
|---|---|---|---|
find_peaks |
TechniqueResult or (E, i) |
CVDiagnostics or list[PeakInfo] |
Parabolic sub-grid peak detection ($E_{pa}, I_{pa}, E_{pc}, I_{pc}, \Delta E_p, |
analyze_randles_sevcik |
Multi-scan-rate results or (v, I_p) |
RandlesSevcikFitResult |
Extracts diffusivity \(D\) from \(I_p\) vs. \(v^{1/2}\) regression. |
analyze_nicholson |
TechniqueResult or (E, i) |
NicholsonDiagnostics |
Extracts \(\Delta E_p\), \(\Psi\), and standard rate constant \(k^0\) via Nicholson's method. |
analyze_levich |
RDESweepResult or results |
LevichFitResult |
Extracts diffusivity \(D\) and Levich constant \(B\) from \(I_L\) vs. \(\omega^{1/2}\). |
analyze_koutecky_levich |
RDESweepResult or results |
KouteckyLevichFitResult |
Separates kinetic current \(I_k\) (\(k^0\)) and mass-transport slope \(B\) (\(D\)). |
analyze_tafel |
TechniqueResult or (\eta, i) |
TafelFitResult |
Extracts exchange current \(I_0\), transfer coefficient \(\alpha\), and Tafel slope \(b\). |
analyze_cottrell |
TechniqueResult or (t, i) |
CottrellFitResult |
Extracts diffusivity \(D\) from \(I\) vs. \(t^{-1/2}\) Cottrell regression. |
analyze_sand |
TechniqueResult or (t, signal) |
SandDiagnostics |
Detects transition time \(\tau\), computes \(I\tau^{1/2}\), and estimates \(D\). |
User Guide & Examples¶
1. Cyclic Voltammetry Sweep, Plotting & Diagnostics¶
from softpotato.reactions import ButlerVolmer, Species
from softpotato.techniques import (
CyclicVoltammetry,
analyze_nicholson,
analyze_randles_sevcik,
find_peaks,
plot_randles_sevcik,
plot_sweep,
simulate,
simulate_sweep,
)
ox = Species(
"Ox",
diffusivity=1e-9,
bulk_concentration=1.0,
standard_potential=0.0,
n_electrons=1,
)
red = Species(
"Red",
diffusivity=1e-9,
bulk_concentration=0.0,
standard_potential=0.0,
n_electrons=-1,
)
kinetics = ButlerVolmer(k0=1e-4, alpha=0.5, E0=0.0, n=1)
# Single CV simulation + declarative plotting
cv = CyclicVoltammetry(E_start=0.4, E_vertex1=-0.4, E_vertex2=0.4, scan_rate=0.1)
res = simulate(cv, [ox, red], kinetics=kinetics)
fig, ax = res.plot() # Default plot ('voltammogram')
fig_sum, axes = res.plot_summary() # 2x2 summary (voltammogram, i_vs_t, E_vs_t, c_vs_x)
# Multi-scan-rate sweep & diagnostics
results = simulate_sweep(
lambda v: CyclicVoltammetry(
E_start=0.4, E_vertex1=-0.4, E_vertex2=0.4, scan_rate=v
),
[ox, red],
values=[0.05, 0.1, 0.2, 0.5],
kinetics=kinetics,
)
plot_sweep(results, legend_title="Scan Rate")
rs_fit = analyze_randles_sevcik(results, n=1, area=1e-4, c_bulk=1.0)
plot_randles_sevcik(results, rs_fit)
nich = analyze_nicholson(res, D=1e-9)
2. Sampled-Current Voltammetry (SCV)¶
from softpotato.reactions import NernstianEquilibrium, Species
from softpotato.techniques import SampledCurrentVoltammetry, plot_scv, simulate
ox = Species(
"Ox",
diffusivity=1e-9,
bulk_concentration=1.0,
standard_potential=0.0,
n_electrons=1,
)
red = Species(
"Red",
diffusivity=1e-9,
bulk_concentration=0.0,
standard_potential=0.0,
n_electrons=-1,
)
scv = SampledCurrentVoltammetry(
E_start=0.3,
E_end=-0.3,
dE=0.05,
duration=2.0,
sample_times=[0.2, 0.5, 1.0, 2.0],
)
res_scv = simulate(scv, [ox, red], kinetics=NernstianEquilibrium(E0=0.0, n=1))
# Extract sampled voltammograms directly or plot with plot_scv / res_scv.plot('scv')
e_steps, i_sampled = res_scv.sample_currents()
fig, ax = plot_scv(res_scv)
3. Interactive Tutorials¶
For complete, runnable notebooks with plots and analytical validation, see:
- Voltammetry & Diagnostics:
tutorials/techniques/cyclic_voltammetry.ipynb— LSV, multi-scan-rate CV sweeps,plot_result/plot_summary/plot_sweep, Randles–Ševčík, and Nicholson \(k^0\) extraction. - Sampled-Current, Pulse Voltammetry & Chronopotentiometry:
tutorials/techniques/pulse_and_cp.ipynb— SCV (plot_scv), DPV (plot_dpv), SWV (plot_swv), and CP with Sand transition-time diagnostics. - Rotating Disk Electrode (RDE):
tutorials/techniques/rde.ipynb— multi-rotation-rate RDE sweeps with Levich and Koutecký–Levich analysis.
Module Contents¶
techniques
¶
Electrochemical experimental techniques and excitation waveform generators.
BaseTechnique
¶
Bases: ABC
Abstract base class for electrochemical experimental techniques.
Encapsulates a time-dependent excitation protocol \(E(t)\) (potentiostatic)
or \(I(t)\) (galvanostatic) over \(t \in [0, t_{\max}]\), together with
exact interior discontinuity/vertex timestamps (event_times) so adaptive
ODE integrators can accurately resolve step edges and switching vertices.
Every BaseTechnique instance is directly callable (technique(t)),
supporting both scalar floats (for solver boundary callables) and NumPy arrays
(for vectorized post-processing and plotting).
Attributes:
| Name | Type | Description |
|---|---|---|
mode |
{'potentiostatic', 'galvanostatic'}
|
Control mode of the excitation waveform (default |
duration |
float
|
Total experiment duration \(t_{\max} > 0\) in seconds. |
event_times |
tuple[float, ...]
|
Sorted strictly interior discontinuity or switching timestamps in \((0, t_{\max})\). |
Source code in src/softpotato/techniques/base.py
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 | |
duration
abstractmethod
property
¶
Total experiment duration in seconds (\(t_{\max} > 0\)).
event_times
property
¶
Sorted interior discontinuity/vertex timestamps in (0, duration).
plot_specs
property
¶
Ordered mapping of canonical plot kind to PlotSpec.
Includes technique-specific plots first (with the primary/default plot
listed first), followed by universal plots ('i_vs_t', 'E_vs_t',
'c_vs_x') without duplicates.
available_plots
property
¶
Ordered tuple of canonical plot kinds supported by this technique.
default_plot
property
¶
Canonical plot kind used by default when plotting results of this technique.
excitation
abstractmethod
¶
Evaluate the excitation signal at time t.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float or array - like
|
Time(s) in seconds at which to evaluate the waveform. |
required |
Returns:
| Type | Description |
|---|---|
float or ndarray
|
Excitation value(s) (potential in V for potentiostatic mode, or
current in A for galvanostatic mode). Returns a Python |
Source code in src/softpotato/techniques/base.py
__call__
¶
potential
¶
Evaluate applied electrode potential \(E(t)\) in Volts.
Only valid for mode='potentiostatic' techniques.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float or array - like
|
Time(s) in seconds. |
required |
Returns:
| Type | Description |
|---|---|
float or ndarray
|
Applied potential \(E(t)\) in Volts. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the technique is not potentiostatic. |
Source code in src/softpotato/techniques/base.py
current
¶
Evaluate applied current \(I(t)\) in Amperes.
Only valid for mode='galvanostatic' techniques.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float or array - like
|
Time(s) in seconds. |
required |
Returns:
| Type | Description |
|---|---|
float or ndarray
|
Applied current \(I(t)\) in Amperes. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the technique is not galvanostatic. |
Source code in src/softpotato/techniques/base.py
time_grid
¶
Generate evaluation timestamps covering [0, duration] and all events.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_points
|
int
|
Number of base uniformly spaced timestamps (must be |
None
|
dt
|
float
|
Base uniform time step in seconds (must be |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Strictly increasing 1D array of timestamps starting at |
Raises:
| Type | Description |
|---|---|
ValueError
|
If both |
Source code in src/softpotato/techniques/base.py
simulate
¶
simulate(mechanism: Mechanism | SpeciesCollection | Sequence[Species] | Species, geometry: Geometry | str = 'planar', grid: ndarray | Mesh1D | None = None, solver: BaseSolver | str = 'scipy_ivp', t_eval: ndarray | Sequence[float] | None = None, solver_kwargs: Mapping[str, Any] | None = None, **kwargs: Any) -> TechniqueResult
Simulate this technique with mechanism via simulate.
Convenience shorthand equivalent to
simulate(self, mechanism, geometry=geometry, grid=grid, solver=solver, t_eval=t_eval, solver_kwargs=solver_kwargs, **kwargs).
Source code in src/softpotato/techniques/base.py
PlotSpec
dataclass
¶
Declarative specification for a plot supported by an electrochemical technique.
Attributes:
| Name | Type | Description |
|---|---|---|
kind |
str
|
Canonical concise plot key (e.g., |
title |
str
|
Default plot title. |
x_label |
str
|
Default horizontal axis label including units. |
y_label |
str
|
Default vertical axis label including units. |
description |
str, default ''
|
Short human-readable description of the plot. |
Source code in src/softpotato/techniques/base.py
Chronoamperometry
¶
Bases: BaseTechnique
Potentiostatic step-potential waveform generator (Chronoamperometry).
Supports three construction modes, each optionally preceded by a resting
(quiet) potential hold (E_quiet, t_quiet):
- Single potential step:
Chronoamperometry(E_step=..., duration=...) - Double potential step:
Chronoamperometry(E_step1=..., E_step2=..., t_step1=..., t_step2=...) - Arbitrary multi-step sequence:
Chronoamperometry(potentials=[...], durations=[...])
At step transitions \(t = t_k\), the waveform is right-continuous: \(E(t) = E_k\) for \(t \in [t_k, t_{k+1})\), and \(E(t_{\max}) = E_{\text{last}}\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
E_step
|
float
|
Single-step applied potential in Volts. Must be paired with |
None
|
duration
|
float
|
Single-step duration in seconds (\(> 0\)). Must be paired with |
None
|
E_step1
|
float
|
First step potential in Volts for double-step chronoamperometry. |
None
|
E_step2
|
float
|
Second (reversal) step potential in Volts for double-step chronoamperometry. |
None
|
t_step1
|
float
|
First step duration in seconds (\(> 0\)). |
None
|
t_step2
|
float
|
Second step duration in seconds (\(> 0\)). |
None
|
potentials
|
Sequence[float]
|
Ordered sequence of step potentials in Volts for multi-step experiments. |
None
|
durations
|
Sequence[float]
|
Ordered sequence of step durations in seconds (\(> 0\)), matching
the length of |
None
|
E_quiet
|
float
|
Optional initial quiet/resting potential in Volts applied before the
first step when |
None
|
t_quiet
|
float
|
Optional initial quiet/resting duration in seconds (\(\ge 0\)).
If |
0.0
|
Examples:
Single-step Cottrell experiment:
>>> from softpotato.techniques import Chronoamperometry
>>> ca = Chronoamperometry(E_step=-0.5, duration=5.0)
>>> ca.duration
5.0
>>> ca(2.5)
-0.5
Double-step chronoamperometry:
>>> dca = Chronoamperometry(E_step1=-0.5, E_step2=0.5, t_step1=2.0, t_step2=3.0)
>>> dca.event_times
(2.0,)
>>> dca(1.9), dca(2.0), dca(5.0)
(-0.5, 0.5, 0.5)
Source code in src/softpotato/techniques/chronoamperometry.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | |
Chronopotentiometry
¶
Bases: BaseTechnique
Galvanostatic step-current waveform generator (Chronopotentiometry).
Supports two construction modes, each optionally preceded by an initial
resting/quiet current hold (I_quiet, t_quiet):
- Single constant current step:
Chronopotentiometry(current=..., duration=...) - Multi-step current sequence (e.g., current-reversal chronopotentiometry):
Chronopotentiometry(currents=[...], durations=[...])
Uses IUPAC polarity conventions: negative current (\(I < 0\)) is cathodic (reduction) and positive current (\(I > 0\)) is anodic (oxidation).
At step transitions \(t = t_k\), the waveform is right-continuous: \(I(t) = I_k\) for \(t \in [t_k, t_{k+1})\), and \(I(t_{\max}) = I_{\text{last}}\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current
|
float
|
Constant applied current \(I\) in Amperes. Must be paired with
|
None
|
duration
|
float
|
Single-step duration in seconds (\(> 0\)). Must be paired with
|
None
|
currents
|
Sequence[float]
|
Ordered sequence of applied currents in Amperes for multi-step experiments (such as current-reversal chronopotentiometry). |
None
|
durations
|
Sequence[float]
|
Ordered sequence of step durations in seconds (\(> 0\)), matching
the length of |
None
|
I_quiet
|
float
|
Optional initial quiet/resting current in Amperes applied before the
first step when |
None
|
t_quiet
|
float
|
Optional initial quiet/resting duration in seconds (\(\ge 0\)).
If |
0.0
|
Examples:
Constant-current cathodic chronopotentiometry:
>>> from softpotato.techniques import Chronopotentiometry
>>> cp = Chronopotentiometry(current=-1e-4, duration=5.0)
>>> cp.mode
'galvanostatic'
>>> cp(2.5)
-0.0001
Current-reversal chronopotentiometry:
>>> rcp = Chronopotentiometry(currents=[-1e-4, 1e-4], durations=[2.0, 3.0])
>>> rcp.event_times
(2.0,)
>>> rcp(1.5), rcp(2.0)
(-0.0001, 0.0001)
Source code in src/softpotato/techniques/chronopotentiometry.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 | |
currents
property
¶
Ordered tuple of step currents in Amperes (including quiet hold if active).
durations
property
¶
Ordered tuple of step durations in seconds (including quiet hold if active).
event_times
property
¶
Sorted interior current step transition timestamps in (0, duration).
interfacial_flux
¶
interfacial_flux(t: float | ArrayLike, n: float, area: float, *, F: float = FARADAY) -> float | np.ndarray
Compute interfacial molar flux \(J(t) = \frac{I(t)}{n F A}\).
Follows IUPAC polarity conventions: cathodic reduction currents (\(I < 0\)) yield negative flux (\(J < 0\), species consumed at the left electrode boundary), and anodic oxidation currents (\(I > 0\)) yield positive flux (\(J > 0\)).
For direct Neumann boundary condition assignment at the left boundary (\(x = x_0\)) where \(J_{\text{left}} = -D \frac{\partial c}{\partial x}\):
- Oxidized species (consumed on reduction): \(\left.\frac{\partial c_{\text{Ox}}}{\partial x}\right|_{x_0} = -\frac{J(t)}{D_{\text{Ox}}}\)
- Reduced species (generated on reduction): \(\left.\frac{\partial c_{\text{Red}}}{\partial x}\right|_{x_0} = +\frac{J(t)}{D_{\text{Red}}}\)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float or array - like
|
Time(s) in seconds. |
required |
n
|
float
|
Number of electrons transferred per reaction (\(n > 0\)). |
required |
area
|
float
|
Active electrode surface area \(A > 0\) in \(\text{m}^2\) or \(\text{cm}^2\). |
required |
F
|
float
|
Faraday constant in \(\text{C}/\text{mol}\) (\(F > 0\)). |
FARADAY
|
Returns:
| Type | Description |
|---|---|
float or ndarray
|
Interfacial molar flux \(J(t)\) in \(\text{mol}/(\text{m}^2\cdot\text{s})\) or \(\text{mol}/(\text{cm}^2\cdot\text{s})\). |
Source code in src/softpotato/techniques/chronopotentiometry.py
recover_potential
¶
recover_potential(c_ox: float | ArrayLike, c_red: float | ArrayLike, *, E0: float = 0.0, n: float = 1.0, T: float = STANDARD_TEMPERATURE, R: float = GAS_CONSTANT, F: float = FARADAY, kinetics: HeterogeneousKinetics | None = None, t: float | ArrayLike | None = None, current: float | ArrayLike | None = None, area: float | None = None) -> float | np.ndarray
Recover electrode surface potential \(E(t)\) from surface concentrations.
-
Reversible (Nernstian) recovery (
kinetics=None):\[ E(t) = E^{0\prime} + \frac{R T}{n F} \ln\left(\frac{c_{\text{Ox}}(0, t)}{c_{\text{Red}}(0, t)}\right) \] -
Finite-rate (Butler–Volmer / heterogeneous kinetics) recovery (
kineticsprovided): solves \(j_{\text{kinetics}}(E, c_{\text{Ox}}, c_{\text{Red}}) = I(t) / A\) for \(E(t)\) via safeguarded root-finding (scipy.optimize.brentq).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c_ox
|
float or array - like
|
Surface concentration of oxidized species \(c_{\text{Ox}}(0, t)\). |
required |
c_red
|
float or array - like
|
Surface concentration of reduced species \(c_{\text{Red}}(0, t)\). |
required |
E0
|
float
|
Formal potential \(E^{0\prime}\) in Volts (used when |
0.0
|
n
|
float
|
Number of electrons transferred (\(n > 0\), used when |
1.0
|
T
|
float
|
Temperature in Kelvin (\(T > 0\), used when |
STANDARD_TEMPERATURE
|
R
|
float
|
Molar gas constant (\(R > 0\), used when |
GAS_CONSTANT
|
F
|
float
|
Faraday constant (\(F > 0\), used when |
FARADAY
|
kinetics
|
HeterogeneousKinetics
|
Optional heterogeneous kinetics model (e.g., |
None
|
t
|
float or array - like
|
Time(s) in seconds used to evaluate |
None
|
current
|
float or array - like
|
Explicit applied current(s) in Amperes when |
None
|
area
|
float
|
Electrode surface area \(A > 0\) (required when |
None
|
Returns:
| Type | Description |
|---|---|
float or ndarray
|
Recovered electrode potential \(E(t)\) in Volts. Returns |
Source code in src/softpotato/techniques/chronopotentiometry.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 | |
detect_transition_time
staticmethod
¶
detect_transition_time(t: ArrayLike, c_surface: ArrayLike, *, threshold: float = 0.001, relative: bool = True) -> float | None
Detect the chronopotentiometric transition time \(\tau\).
Finds the earliest timestamp \(\tau\) at which the electroactive reactant surface concentration \(c(0, t)\) depletes to or below the specified threshold, using linear interpolation between adjacent samples.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
array - like
|
Strictly increasing 1D time array in seconds. |
required |
c_surface
|
array - like
|
1D surface concentration array \(c(0, t)\) matching |
required |
threshold
|
float
|
Depletion threshold (\(\ge 0\)). When |
1e-3
|
relative
|
bool
|
Whether |
True
|
Returns:
| Type | Description |
|---|---|
float or None
|
Interpolated transition time \(\tau\) in seconds, or |
Source code in src/softpotato/techniques/chronopotentiometry.py
CVDiagnostics
dataclass
¶
Summary voltammetric peak diagnostics for a CV or LSV trace.
Attributes:
| Name | Type | Description |
|---|---|---|
anodic_peak |
PeakInfo or None
|
Dominant anodic (positive current) peak, or |
cathodic_peak |
PeakInfo or None
|
Dominant cathodic (negative current) peak, or |
delta_Ep |
float or None
|
Peak-to-peak separation \(\Delta E_p = |E_{pa} - E_{pc}|\) in Volts
when both peaks are detected, otherwise |
E_half |
float or None
|
Midpoint potential \(E_{1/2} = \frac{1}{2}(E_{pa} + E_{pc})\) in
Volts when both peaks are detected, otherwise |
peak_current_ratio |
float or None
|
Magnitude ratio \(|I_{pa} / I_{pc}|\) when both peaks are detected
and \(I_{pc} \neq 0\), otherwise |
Source code in src/softpotato/techniques/diagnostics.py
NicholsonDiagnostics
dataclass
¶
Combined Nicholson and Matsuda–Ayabe kinetic diagnostics for CV.
Attributes:
| Name | Type | Description |
|---|---|---|
delta_Ep |
float
|
Peak-to-peak potential separation \(\Delta E_p\) in Volts. |
delta_Ep_mv |
float
|
Peak-to-peak potential separation \(\Delta E_p\) in millivolts. |
psi |
float
|
Dimensionless Nicholson kinetic parameter \(\Psi\). |
k0 |
float
|
Extracted standard heterogeneous rate constant \(k^0\) in units consistent with \(D\) (e.g., \(\text{m}/\text{s}\) or \(\text{cm}/\text{s}\)). |
lambda_param |
float
|
Dimensionless Matsuda–Ayabe reversibility parameter \(\Lambda = \sqrt{\pi}\,\Psi\). |
regime |
{'reversible', 'quasi-reversible', 'irreversible'}
|
Matsuda–Ayabe kinetic reversibility classification. |
nicholson |
NicholsonResult
|
Underlying |
matsuda_ayabe |
MatsudaAyabeResult
|
Underlying |
peaks |
CVDiagnostics or None
|
Detected voltammetric peaks when analyzed from a |
Source code in src/softpotato/techniques/diagnostics.py
PeakInfo
dataclass
¶
Metadata for a single detected voltammetric current peak.
Attributes:
| Name | Type | Description |
|---|---|---|
E_peak |
float
|
Peak potential \(E_p\) in Volts (parabolically refined when enabled). |
I_peak |
float
|
Peak current \(I_p\) in Amperes under IUPAC polarity conventions (positive for anodic, negative for cathodic). |
index |
int
|
Discrete sample index of the detected local extremum in the analyzed potential/current arrays. |
E_half_peak |
float or None
|
Half-peak potential \(E_{p/2}\) in Volts on the rising (pre-peak)
flank where \(I = I_p / 2\), or |
polarity |
{'anodic', 'cathodic'}
|
Peak polarity: |
Source code in src/softpotato/techniques/diagnostics.py
SandDiagnostics
dataclass
¶
Diagnostic summary for galvanostatic chronopotentiometry (Sand analysis).
Attributes:
| Name | Type | Description |
|---|---|---|
tau |
float or None
|
Detected transition time \(\tau\) in seconds, or |
tau_theoretical |
float or None
|
Theoretical Sand transition time from
|
relative_error |
float or None
|
Relative error \(|\tau - \tau_{\text{th}}| / \tau_{\text{th}}\)
when both |
sand_constant |
float or None
|
Experimental Sand product \(|I|\sqrt{\tau}\) in
\(\text{A}\cdot\text{s}^{1/2}\) when |
D_estimated |
float or None
|
Diffusion coefficient \(D = \frac{4 I^2 \tau}{\pi (n F A c^*)^2}\) estimated from the detected transition time. |
current |
float
|
Applied galvanostatic current \(I\) in Amperes (signed IUPAC). |
detection_method |
{'concentration', 'potential', 'none'}
|
Signal source used to detect \(\tau\). |
Source code in src/softpotato/techniques/diagnostics.py
DifferentialPulseVoltammetry
¶
Bases: BaseTechnique
Differential Pulse Voltammetry (DPV) waveform generator.
Superimposes constant-amplitude potential pulses \(\Delta E_p\) of width \(t_p\) onto a linear staircase ramp from \(E_{\text{start}}\) to \(E_{\text{end}}\) with step increment \(\Delta E_s > 0\) and cycle period \(\tau > t_p\).
Within each cycle \(k \in \{0, \dots, N-1\}\) over \([k\tau, (k+1)\tau)\):
- Base hold (\(t \in [k\tau, k\tau + \tau - t_p)\)): \(E(t) = E_{\text{base}, k}\)
- Pulse hold (\(t \in [k\tau + \tau - t_p, (k+1)\tau)\)): \(E(t) = E_{\text{base}, k} + \Delta E_p\)
Currents are sampled near the end of each base hold (\(I_{\text{pre}}\))
and near the end of each pulse hold (\(I_{\text{pulse}}\)) via
sample_currents, yielding \(\Delta I = I_{\text{pulse}} - I_{\text{pre}}\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
E_start
|
float
|
Initial staircase base potential in Volts. |
required |
E_end
|
float
|
Final staircase base potential in Volts (must differ from |
required |
step_height
|
float
|
Staircase potential step magnitude \(\Delta E_s > 0\) in Volts. |
required |
pulse_amplitude
|
float
|
Pulse potential amplitude \(\Delta E_p \neq 0\) in Volts (positive for anodic pulses, negative for cathodic pulses). |
required |
pulse_width
|
float
|
Pulse duration \(t_p > 0\) in seconds. |
required |
pulse_period
|
float
|
Total cycle period \(\tau > t_p\) in seconds. |
required |
sample_fraction
|
float
|
Fraction \(\in (0, 1]\) of the base/pulse segment duration near the
end of each segment over which current is averaged in |
0.1
|
Examples:
>>> from softpotato.techniques import DifferentialPulseVoltammetry
>>> dpv = DifferentialPulseVoltammetry(
... E_start=0.2,
... E_end=-0.2,
... step_height=0.05,
... pulse_amplitude=-0.025,
... pulse_width=0.05,
... pulse_period=0.5,
... )
>>> dpv.n_steps
9
>>> dpv.duration
4.5
Source code in src/softpotato/techniques/pulse.py
544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 | |
step_height
property
¶
Staircase potential step magnitude \(\Delta E_s\) in Volts.
pulse_amplitude
property
¶
Pulse potential amplitude \(\Delta E_p\) in Volts.
sample_fraction
property
¶
Sampling window fraction near the end of each base/pulse segment.
base_potentials
property
¶
Ordered tuple of staircase base potentials \(E_{\text{base}, k}\) in Volts.
pulse_potentials
property
¶
Ordered tuple of pulse potentials \(E_{\text{base}, k} + \Delta E_p\) in Volts.
event_times
property
¶
Sorted interior pulse rise and fall timestamps in (0, duration).
sample_currents
¶
sample_currents(t: ArrayLike, i: ArrayLike) -> tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]
Sample pre-pulse, pulse, and differential currents across all steps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
array - like
|
Strictly increasing 1D time array in seconds. |
required |
i
|
array - like
|
1D Faradaic current array in Amperes matching |
required |
Returns:
| Name | Type | Description |
|---|---|---|
E_base |
ndarray
|
Staircase base potentials of shape |
i_pre |
ndarray
|
Currents sampled near the end of each base hold, shape |
i_pulse |
ndarray
|
Currents sampled near the end of each pulse hold, shape |
i_diff |
ndarray
|
Differential current |
Source code in src/softpotato/techniques/pulse.py
SampledCurrentVoltammetry
¶
Bases: BaseTechnique
Sampled-Current Voltammetry (SCV) potential-step family generator.
Applies a series of independent constant-potential steps across a potential window, where every step shares the exact same total duration \(t_{\max}\) and evaluation time grid. Sampling the resulting current transients \(I_k(t)\) at one or more fixed sampling times \(\tau \in (0, t_{\max}]\) yields the sampled-current voltammogram \(I(\tau)\) vs. \(E_k\).
Supports two mutually exclusive ways to specify the step potentials:
- Explicit potentials:
SampledCurrentVoltammetry(potentials=[...], duration=...)accepting a Python list, tuple, or 1D NumPy array of potentials. - Potential window + step:
SampledCurrentVoltammetry(E_start=..., E_end=..., dE=..., duration=...)(orstep_height=...as an alias fordE).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
potentials
|
Sequence[float] or ndarray
|
Explicit 1D sequence or NumPy array of step potentials in Volts.
Mutually exclusive with |
None
|
duration
|
float
|
Constant-potential step duration in seconds (\(> 0\)) applied uniformly to every potential step. Required. |
None
|
E_start
|
float
|
Initial potential of the potential window in Volts. |
None
|
E_end
|
float
|
Final potential of the potential window in Volts (must differ from
|
None
|
dE
|
float
|
Potential step increment \(\Delta E > 0\) in Volts used with
|
None
|
step_height
|
float
|
Alias for |
None
|
E_quiet
|
float
|
Optional initial quiet/resting potential in Volts applied before every
step when |
None
|
t_quiet
|
float
|
Optional initial quiet/resting duration in seconds (\(\ge 0\))
applied identically to every step. If |
0.0
|
sample_times
|
float or Sequence[float] or ndarray
|
Optional default sampling time(s) \(\tau \in (0, t_{\max}]\) in
seconds for |
None
|
n_points
|
int
|
Optional default number of points (\(\ge 2\)) for |
None
|
Examples:
From an explicit list or NumPy array:
>>> import numpy as np
>>> from softpotato.techniques import SampledCurrentVoltammetry
>>> scv = SampledCurrentVoltammetry(potentials=[-0.4, -0.2, 0.0, 0.2], duration=5.0)
>>> scv.n_steps
4
>>> scv.duration
5.0
From a potential window and step increment:
>>> scv_win = SampledCurrentVoltammetry(
... E_start=0.2, E_end=-0.2, dE=0.1, duration=2.0
... )
>>> len(scv_win)
5
>>> tuple(round(e, 4) for e in scv_win.potentials)
(0.2, 0.1, 0.0, -0.1, -0.2)
Source code in src/softpotato/techniques/pulse.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 | |
potentials
property
¶
Ordered tuple of constant step potentials in Volts.
step_duration
property
¶
Duration of the constant-potential hold in seconds (same for all steps).
duration
property
¶
Total duration t_quiet + step_duration in seconds (same for all steps).
dE
property
¶
Potential step increment in Volts if constructed in window mode, else None.
sample_times
property
¶
Default sampling times in seconds, or None.
steps
property
¶
Tuple of Chronoamperometry objects, one per potential step.
event_times
property
¶
Sorted interior transition timestamps shared by all steps.
excitation
¶
Evaluate applied potentials across all steps at time(s) t.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float or array - like
|
Time(s) in seconds. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
For scalar |
Source code in src/softpotato/techniques/pulse.py
sample_currents
¶
sample_currents(t: ArrayLike, currents: ArrayLike, sample_times: float | Sequence[float] | ndarray | None = None) -> tuple[np.ndarray, np.ndarray]
Extract sampled-current voltammogram(s) from step current transients.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
array - like
|
Shared strictly increasing 1D time array of shape |
required |
currents
|
array - like
|
2D array (or sequence of 1D arrays) of shape |
required |
sample_times
|
float or Sequence[float] or ndarray
|
Sampling time(s) \(\tau \in (0, t_{\max}]\) in seconds.
Defaults to |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
potentials |
ndarray
|
1D array of step potentials of shape |
sampled_currents |
ndarray
|
1D array of shape |
Source code in src/softpotato/techniques/pulse.py
SquareWaveVoltammetry
¶
Bases: BaseTechnique
Osteryoung Square-Wave Voltammetry (SWV) waveform generator.
Superimposes a symmetric square wave of amplitude \(E_{\text{sw}} > 0\) and frequency \(f > 0\) (period \(\tau = 1/f\), half-period \(t_p = 1/(2f)\)) onto a linear staircase ramp from \(E_{\text{start}}\) to \(E_{\text{end}}\) with step height \(\Delta E_s > 0\).
Within each cycle \(k \in \{0, \dots, N-1\}\) over \([k\tau, (k+1)\tau)\) with scan direction \(s = \operatorname{sgn}(E_{\text{end}} - E_{\text{start}}) \in \{+1, -1\}\):
- Forward half-cycle (\(t \in [k\tau, k\tau + t_p)\)): \(E(t) = E_{\text{step}, k} + s \, E_{\text{sw}}\)
- Reverse half-cycle (\(t \in [k\tau + t_p, (k+1)\tau)\)): \(E(t) = E_{\text{step}, k} - s \, E_{\text{sw}}\)
Currents are sampled near the end of each forward (\(I_f\)) and reverse
(\(I_r\)) half-period via sample_currents, yielding the net
square-wave current \(\Delta I = I_f - I_r\) under IUPAC polarity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
E_start
|
float
|
Initial staircase potential in Volts. |
required |
E_end
|
float
|
Final staircase potential in Volts (must differ from |
required |
step_height
|
float
|
Staircase potential step magnitude \(\Delta E_s > 0\) in Volts. |
required |
amplitude
|
float
|
Square-wave pulse amplitude \(E_{\text{sw}} > 0\) in Volts. |
required |
frequency
|
float
|
Square-wave frequency \(f > 0\) in Hz. |
required |
sample_fraction
|
float
|
Fraction \(\in (0, 1]\) of each half-period near the end of the
half-cycle over which current is averaged in |
0.1
|
Examples:
>>> from softpotato.techniques import SquareWaveVoltammetry
>>> swv = SquareWaveVoltammetry(
... E_start=0.2,
... E_end=-0.2,
... step_height=0.05,
... amplitude=0.025,
... frequency=10.0,
... )
>>> swv.n_steps
9
>>> swv.period
0.1
>>> swv.half_period
0.05
Source code in src/softpotato/techniques/pulse.py
838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 | |
step_height
property
¶
Staircase potential step magnitude \(\Delta E_s\) in Volts.
sample_fraction
property
¶
Sampling window fraction near the end of each half-cycle.
step_potentials
property
¶
Ordered tuple of staircase step potentials \(E_{\text{step}, k}\) in Volts.
forward_potentials
property
¶
Ordered tuple of forward half-cycle potentials in Volts.
reverse_potentials
property
¶
Ordered tuple of reverse half-cycle potentials in Volts.
event_times
property
¶
Sorted interior half-period transition timestamps in (0, duration).
sample_currents
¶
sample_currents(t: ArrayLike, i: ArrayLike) -> tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]
Sample forward, reverse, and net currents across all square-wave cycles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
array - like
|
Strictly increasing 1D time array in seconds. |
required |
i
|
array - like
|
1D Faradaic current array in Amperes matching |
required |
Returns:
| Name | Type | Description |
|---|---|---|
E_step |
ndarray
|
Staircase potentials of shape |
i_forward |
ndarray
|
Forward half-cycle currents of shape |
i_reverse |
ndarray
|
Reverse half-cycle currents of shape |
i_net |
ndarray
|
Net square-wave current |
Source code in src/softpotato/techniques/pulse.py
RDEConvectionTerm
¶
Axial convective transport operator \(-v_x(x) \partial c/\partial x\) for RDE.
Implements the reactions protocol expected by
DiffusionProblem and
ScipyIVPSolver, optionally composing with an
existing homogeneous reaction network or callable while supplying an exact
sparse analytical Jacobian when possible.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
omega
|
float
|
Angular rotation velocity \(\omega > 0\) in \(\text{rad}/\text{s}\). |
required |
kinematic_viscosity
|
float
|
Kinematic viscosity \(\nu > 0\) in \(\text{m}^2/\text{s}\). |
required |
diffusivity
|
float or Mapping[str, float]
|
Scalar diffusion coefficient or per-species diffusivity mapping used for local Péclet number evaluation. |
required |
base_reactions
|
Any
|
Optional homogeneous reaction term ( |
None
|
Source code in src/softpotato/techniques/rde.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 | |
jacobian
¶
jacobian(c_dict: dict[str, ndarray], grid: ndarray, t: float, species: Sequence[str] | None = None) -> sparse.csc_matrix
Assemble full sparse Jacobian (S*N, S*N) for convection + reactions.
Source code in src/softpotato/techniques/rde.py
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 | |
__call__
¶
Evaluate convective rate (plus optional homogeneous reactions) for each species.
Source code in src/softpotato/techniques/rde.py
RDESweep
¶
Multi-rotation-rate Rotating Disk Electrode (RDE) sweep configuration.
Generates an ordered collection of RotatingDiskElectrode
instances sharing the same potential waveform, electrolyte viscosity, and
hydrodynamic transport model across a series of rotation rates
\(\{\omega_1, \dots, \omega_M\}\) for Levich and Koutecký–Levich
analysis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
waveform
|
BaseTechnique
|
Shared potentiostatic excitation waveform. Mutually exclusive with
direct LSV parameters ( |
None
|
omegas
|
Sequence[float] or array - like
|
Sequence of positive angular rotation velocities in
\(\text{rad}/\text{s}\). Mutually exclusive with |
None
|
rpms
|
Sequence[float] or array - like
|
Sequence of positive rotational speeds in RPM. Mutually exclusive with
|
None
|
kinematic_viscosity
|
float
|
Electrolyte kinematic viscosity \(\nu > 0\) in \(\text{m}^2/\text{s}\). |
1e-6
|
model
|
('nernst_layer', 'convective_diffusion')
|
Hydrodynamic mass-transport model. |
'nernst_layer'
|
E_start
|
optional
|
Direct LSV waveform parameters when |
None
|
E_end
|
optional
|
Direct LSV waveform parameters when |
None
|
scan_rate
|
optional
|
Direct LSV waveform parameters when |
None
|
dE
|
optional
|
Direct LSV waveform parameters when |
None
|
n_points
|
optional
|
Direct LSV waveform parameters when |
None
|
domain_factor
|
float
|
Domain multiplier \(k > 0\) applied to \(\delta_N\). |
None
|
Examples:
>>> from softpotato.techniques import RDESweep
>>> sweep = RDESweep(
... E_start=0.5, E_end=-0.5, scan_rate=0.05, rpms=[400, 900, 1600, 2500]
... )
>>> len(sweep)
4
Source code in src/softpotato/techniques/rde.py
1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 | |
omegas
property
¶
1D array of angular rotation velocities \(\omega\) in \(\text{rad}/\text{s}\).
kinematic_viscosity
property
¶
Kinematic viscosity \(\nu\) in \(\text{m}^2/\text{s}\).
techniques
property
¶
Tuple of configured RotatingDiskElectrode instances.
diffusion_layer_thicknesses
¶
Compute Nernst diffusion layer thickness \(\delta_N(\omega)\) for each rate.
Source code in src/softpotato/techniques/rde.py
simulate
¶
simulate(*, D: float | None = None, diffusivity: Mapping[str, float] | None = None, c_bulk: float = 1.0, initial_conditions: Mapping[str, Any] | None = None, boundary_conditions: Mapping[str, tuple[BoundaryCondition, BoundaryCondition]] | None = None, kinetics: HeterogeneousKinetics | NernstianEquilibrium | None = None, species_name: str = 'Ox', red_species_name: str = 'Red', c_red_bulk: float = 0.0, n_electrons: int | Mapping[str, int] = 1, area: float = 1.0, reactions: Any = None, n_points: int = 80, grid_kind: str = 'geometric', gamma: float = 1.06, beta: float = 3.0, domain_factor: float | None = None, solver: str = 'scipy_ivp', t_eval: ndarray | None = None, solver_kwargs: Mapping[str, Any] | None = None) -> RDESweepResult
Run the PDE simulation across all rotation rates in this sweep.
Source code in src/softpotato/techniques/rde.py
RDESweepResult
dataclass
¶
Container for multi-rotation-rate RDE simulation sweep results.
Attributes:
| Name | Type | Description |
|---|---|---|
omegas |
ndarray
|
Angular rotation velocities \(\omega\) in \(\text{rad}/\text{s}\)
of shape |
rpms |
ndarray
|
Rotational speeds in RPM of shape |
results |
tuple[SolverResult, ...]
|
Individual |
limiting_currents |
ndarray
|
Final-time (steady-state) Faradaic current of |
techniques |
tuple[RotatingDiskElectrode, ...]
|
Configured |
species |
str
|
Primary species name used to populate |
Source code in src/softpotato/techniques/rde.py
RotatingDiskElectrode
¶
Bases: BaseTechnique
Rotating Disk Electrode (RDE) hydrodynamic electrochemical technique.
Wraps an underlying potentiostatic excitation waveform
(LinearSweepVoltammetry,
CyclicVoltammetry,
Chronoamperometry, or any potentiostatic
BaseTechnique) and couples it with
rotation-dependent hydrodynamic mass transport:
-
model="nernst_layer"(default): Nernst stagnant diffusion layer approximation on \(x \in [0, \delta_N]\) with bulk Dirichlet boundary condition at \(x = \delta_N\), where\[ \delta_N = 1.610 \, D^{1/3} \nu^{1/6} \omega^{-1/2} \] -
model="convective_diffusion": Full Levich axial convective-diffusion PDE on \(x \in [0, k \delta_N]\) (default \(k = 3.0\)) including the von Kármán axial fluid velocity toward the disk:\[ v_x(x) = -0.51023 \, \omega^{3/2} \nu^{-1/2} x^2 \]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
waveform
|
BaseTechnique
|
Underlying potentiostatic excitation waveform (e.g., LSV, CV, or CA).
Mutually exclusive with direct LSV parameters
( |
None
|
omega
|
float
|
Angular rotation velocity \(\omega > 0\) in \(\text{rad}/\text{s}\).
Mutually exclusive with |
None
|
rpm
|
float
|
Rotational speed in revolutions per minute (\(\text{rpm} > 0\)),
converted to \(\omega\) via
|
None
|
kinematic_viscosity
|
float
|
Electrolyte kinematic viscosity \(\nu > 0\) in \(\text{m}^2/\text{s}\)
(default |
1e-6
|
model
|
('nernst_layer', 'convective_diffusion')
|
Hydrodynamic mass-transport model. |
'nernst_layer'
|
E_start
|
float
|
Initial potential in Volts when constructing a default LSV waveform. |
None
|
E_end
|
float
|
Final potential in Volts when constructing a default LSV waveform. |
None
|
scan_rate
|
float
|
Scan rate magnitude in V/s when constructing a default LSV waveform. |
None
|
dE
|
float
|
Default potential step resolution in Volts for the default LSV waveform. |
None
|
n_points
|
int
|
Default number of time grid points for the default LSV waveform. |
None
|
domain_factor
|
float
|
Multiplier \(k > 0\) applied to \(\delta_N\) when constructing
spatial grids via |
None
|
Examples:
>>> from softpotato.techniques import RotatingDiskElectrode
>>> rde = RotatingDiskElectrode(
... E_start=0.5, E_end=-0.5, scan_rate=0.05, rpm=1600
... )
>>> round(rde.omega, 2)
167.55
>>> round(rde.diffusion_layer_thickness(D=1e-9) * 1e6, 2)
12.44
Source code in src/softpotato/techniques/rde.py
427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 | |
kinematic_viscosity
property
¶
Kinematic viscosity \(\nu\) in \(\text{m}^2/\text{s}\).
model
property
¶
Hydrodynamic mass-transport model ('nernst_layer' or 'convective_diffusion').
domain_factor
property
¶
Domain multiplier \(k\) such that \(x_{\max} = k \delta_N\).
event_times
property
¶
Sorted interior event timestamps (delegated to waveform).
time_grid
¶
Generate evaluation timestamps (delegated to waveform).
Source code in src/softpotato/techniques/rde.py
diffusion_layer_thickness
¶
Compute the Nernst stagnant diffusion layer thickness \(\delta_N\).
Delegates to nernst_diffusion_layer:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
D
|
float
|
Diffusion coefficient \(D > 0\) in consistent units with
|
required |
Returns:
| Type | Description |
|---|---|
float
|
Diffusion layer thickness \(\delta_N > 0\). |
Source code in src/softpotato/techniques/rde.py
axial_velocity
¶
Evaluate the von Kármán axial fluid velocity \(v_x(x)\) toward the disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float or array - like
|
Axial distance(s) from the disk electrode surface (\(x \ge 0\)). |
required |
Returns:
| Type | Description |
|---|---|
float or ndarray
|
Axial velocity \(v_x(x) \le 0\) in \(\text{m}/\text{s}\) (or consistent units). |
Source code in src/softpotato/techniques/rde.py
build_grid
¶
build_grid(D: float, n_points: int = 80, kind: str = 'geometric', gamma: float = 1.06, *, beta: float = 3.0, domain_factor: float | None = None) -> Mesh1D
Construct a 1D spatial mesh bounded by the hydrodynamic diffusion layer.
For model="nernst_layer", the default domain is \([0, \delta_N]\).
For model="convective_diffusion", the default domain is
\([0, k \cdot \delta_N]\) with \(k = 3.0\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
D
|
float
|
Reference diffusion coefficient \(D > 0\). |
required |
n_points
|
int
|
Number of spatial grid nodes (\(\ge 3\)). |
80
|
kind
|
('geometric', 'exponential', 'uniform')
|
Mesh discretization family. |
'geometric'
|
gamma
|
float
|
Geometric expansion ratio \(\gamma > 1\) (used when
|
1.06
|
beta
|
float
|
Exponential stretching factor \(\beta > 0\) (used when
|
3.0
|
domain_factor
|
float
|
Override for |
None
|
Returns:
| Type | Description |
|---|---|
Mesh1D
|
Constructed 1D spatial mesh spanning \([0, k \delta_N]\). |
Source code in src/softpotato/techniques/rde.py
convection_term
¶
convection_term(diffusivity: float | Mapping[str, float], *, reactions: Any = None) -> RDEConvectionTerm
Create an RDEConvectionTerm for DiffusionProblem(reactions=...).
Source code in src/softpotato/techniques/rde.py
levich_limiting_current
¶
levich_limiting_current(*, n: float = 1, D: float = 1e-09, c_bulk: float = 1.0, area: float = 1.0) -> float
Compute the analytical Levich limiting current \(I_L\) at this rotation rate.
Delegates to levich.
Source code in src/softpotato/techniques/rde.py
with_rotation
¶
Return a copy of this RDE technique at a different rotation rate.
Source code in src/softpotato/techniques/rde.py
build_problem
¶
build_problem(*, D: float | None = None, diffusivity: Mapping[str, float] | None = None, c_bulk: float = 1.0, initial_conditions: Mapping[str, Any] | None = None, boundary_conditions: Mapping[str, tuple[BoundaryCondition, BoundaryCondition]] | None = None, kinetics: HeterogeneousKinetics | NernstianEquilibrium | None = None, species_name: str = 'Ox', red_species_name: str = 'Red', c_red_bulk: float = 0.0, n_electrons: int | Mapping[str, int] = 1, area: float = 1.0, reactions: Any = None, n_points: int = 80, grid_kind: str = 'geometric', gamma: float = 1.06, beta: float = 3.0, domain_factor: float | None = None) -> DiffusionProblem
Build a configured DiffusionProblem for this RDE.
Automatically sizes the spatial mesh to the hydrodynamic diffusion
layer, attaches bulk Dirichlet outer boundary conditions, and injects
the axial convective velocity operator when
model="convective_diffusion".
Source code in src/softpotato/techniques/rde.py
811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 | |
TechniqueResult
dataclass
¶
Structured container for the output of simulate.
Wraps the underlying SolverResult with
electrochemical observables (time, potential, current, charge),
dict-like species concentration profile access (result["Ox"]), and
technique-specific convenience views (CV cycles, SWV E_step /
i_forward / i_reverse / i_net, DPV E_base / i_pre /
i_pulse / i_diff, and CP transition_time).
Attributes:
| Name | Type | Description |
|---|---|---|
technique |
BaseTechnique
|
The executed electrochemical technique specification. |
solver_result |
SolverResult
|
Underlying full PDE solution containing species concentration profiles, interfacial fluxes, per-species currents, spatial grid, and solver status. |
time |
ndarray
|
1D array of evaluation timestamps \(t\) in seconds. |
potential |
ndarray
|
Electrode potential \(E(t)\) in Volts (applied waveform for potentiostatic techniques; recovered surface potential for galvanostatic chronopotentiometry when kinetics/redox metadata are available). |
current |
ndarray
|
Net Faradaic current \(I(t)\) in Amperes under IUPAC polarity conventions (anodic positive, cathodic negative). |
charge |
ndarray
|
Cumulative charge \(Q(t) = \int_0^t I(\tau)\,d\tau\) in Coulombs computed via trapezoidal integration. Automatically computed if omitted. |
metadata |
dict[str, Any]
|
Auxiliary execution metadata (solver name, geometry, segment count,
technique-specific quantities such as |
Source code in src/softpotato/techniques/result.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 | |
concentrations
property
¶
Mapping from species name to 2D concentration profile (N_t, N_x).
fluxes
property
¶
Mapping from species name to left-boundary interfacial flux (N_t,).
currents
property
¶
Mapping from species name to per-species Faradaic current (N_t,).
cycles
property
¶
Per-cycle TechniqueResult slices for CyclicVoltammetry.
Returns:
| Type | Description |
|---|---|
tuple[TechniqueResult, ...]
|
One sliced |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
i_forward
property
¶
Forward half-cycle sampled currents for SquareWaveVoltammetry.
i_reverse
property
¶
Reverse half-cycle sampled currents for SquareWaveVoltammetry.
i_net
property
¶
Net square-wave current i_forward - i_reverse for SquareWaveVoltammetry.
i_diff
property
¶
Differential current i_pulse - i_pre for DifferentialPulseVoltammetry.
transition_time
property
¶
Detected chronopotentiometric transition time \(\tau\) in seconds, or None.
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
plot_specs
property
¶
Ordered mapping of canonical plot kind to PlotSpec.
available_plots
property
¶
Ordered tuple of canonical plot kinds supported for this result.
__getitem__
¶
Shorthand to access 2D concentration profile (N_t, N_x) for a species.
sample_currents
¶
sample_currents(sample_times: float | list[float] | tuple[float, ...] | ndarray | None = None) -> tuple[np.ndarray, np.ndarray]
Sample voltammogram(s) at sample_times for SampledCurrentVoltammetry.
Source code in src/softpotato/techniques/result.py
plot
¶
Plot this simulation result using the declarative plotting suite.
Delegates to plot_result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
str
|
Concise plot key (e.g., |
None
|
ax
|
Axes
|
Existing Axes to draw onto. A new figure and axes are created when omitted. |
None
|
**kwargs
|
Any
|
Additional keyword arguments forwarded to the plot renderer. |
{}
|
Returns:
| Type | Description |
|---|---|
tuple[Figure, Axes]
|
Figure and Axes containing the rendered plot. |
Source code in src/softpotato/techniques/result.py
plot_summary
¶
plot_summary(*, t: float | Sequence[float] | None = None, species: str | Sequence[str] | None = None, figsize: tuple[float, float] | None = None, **kwargs: Any) -> tuple[Figure, np.ndarray]
Render a multi-panel overview figure for this simulation result.
Delegates to plot_summary.
Source code in src/softpotato/techniques/result.py
CyclicVoltammetry
¶
Bases: BaseTechnique
Multi-cycle triangular potential waveform generator (Cyclic Voltammetry).
Each cycle sweeps linearly along the vertex sequence:
- \(E_{\text{start}} \to E_{\text{vertex1}} \to E_{\text{vertex2}} \to E_{\text{start}}\) for intermediate cycles (with the final leg omitted when \(E_{\text{vertex2}} = E_{\text{start}}\)), and
- \(E_{\text{start}} \to E_{\text{vertex1}} \to E_{\text{vertex2}} \to E_{\text{end}}\)
for the final cycle (where
E_enddefaults toE_start, and the final leg is omitted when \(E_{\text{end}} = E_{\text{vertex2}}\)).
Exact switching vertex timestamps (where \(dE/dt\) reverses sign) are
recorded in event_times, and per-cycle time intervals are exposed via
cycle_time_ranges.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
E_start
|
float
|
Initial potential \(E_{\text{start}}\) in Volts. |
required |
E_vertex1
|
float
|
First switching vertex potential \(E_{\lambda 1}\) in Volts
(must differ from |
required |
E_vertex2
|
float
|
Second switching vertex potential \(E_{\lambda 2}\) in Volts
(must differ from |
required |
scan_rate
|
float
|
Scan rate magnitude \(v > 0\) in V/s. |
required |
E_end
|
float
|
Final potential at the end of the last cycle in Volts. Defaults to
|
None
|
n_cycles
|
int
|
Number of complete voltammetric cycles (\(\ge 1\)). |
1
|
dE
|
float
|
Default potential step resolution \(\Delta E > 0\) in Volts for
|
None
|
n_points
|
int
|
Default number of points (\(\ge 2\)) for |
None
|
Examples:
>>> from softpotato.techniques import CyclicVoltammetry
>>> cv = CyclicVoltammetry(
... E_start=0.5, E_vertex1=-0.5, E_vertex2=0.5, scan_rate=0.5, n_cycles=2
... )
>>> cv.duration
8.0
>>> cv.event_times
(2.0, 4.0, 6.0)
>>> cv.cycle_time_ranges
((0.0, 4.0), (4.0, 8.0))
Source code in src/softpotato/techniques/voltammetry.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 | |
event_times
property
¶
Sorted switching vertex timestamps where scan direction reverses.
cycle_time_ranges
property
¶
Per-cycle (t_start, t_end) intervals for slicing multi-cycle results.
time_grid
¶
time_grid(n_points: int | None = None, dt: float | None = None, dE: float | None = None) -> np.ndarray
Generate evaluation timestamps including all switching vertices and cycle bounds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_points
|
int
|
Number of uniformly spaced base timestamps ( |
None
|
dt
|
float
|
Uniform time step in seconds ( |
None
|
dE
|
float
|
Uniform potential step in Volts ( |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Strictly increasing 1D array of timestamps in |
Source code in src/softpotato/techniques/voltammetry.py
LinearSweepVoltammetry
¶
Bases: BaseTechnique
Unidirectional linear potential sweep waveform (LSV).
Sweeps electrode potential linearly from \(E_{\text{start}}\) to \(E_{\text{end}}\) at scan rate \(v > 0\) (V/s):
for \(t \in [0, |E_{\text{end}} - E_{\text{start}}| / v]\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
E_start
|
float
|
Initial potential \(E_{\text{start}}\) in Volts. |
required |
E_end
|
float
|
Final potential \(E_{\text{end}}\) in Volts (must differ from |
required |
scan_rate
|
float
|
Scan rate magnitude \(v > 0\) in V/s. |
required |
dE
|
float
|
Default potential step resolution \(\Delta E > 0\) in Volts used by
|
None
|
n_points
|
int
|
Default number of points (\(\ge 2\)) used by |
None
|
Examples:
>>> from softpotato.techniques import LinearSweepVoltammetry
>>> lsv = LinearSweepVoltammetry(E_start=0.5, E_end=-0.5, scan_rate=0.1)
>>> lsv.duration
10.0
>>> lsv(5.0)
0.0
Source code in src/softpotato/techniques/voltammetry.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | |
direction
property
¶
Sweep direction: +1 (anodic/positive) or -1 (cathodic/negative).
duration
property
¶
Total sweep duration \(|E_{\text{end}} - E_{\text{start}}| / v\) in seconds.
time_grid
¶
time_grid(n_points: int | None = None, dt: float | None = None, dE: float | None = None) -> np.ndarray
Generate evaluation timestamps for the linear sweep.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_points
|
int
|
Number of uniformly spaced timestamps ( |
None
|
dt
|
float
|
Uniform time step in seconds ( |
None
|
dE
|
float
|
Uniform potential step in Volts ( |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Strictly increasing 1D array of timestamps in |
Source code in src/softpotato/techniques/voltammetry.py
CallableSegment
¶
Bases: WaveformSegment
Arbitrary user-defined callable segment \(y(\tau) = f(\tau)\).
Supports both vectorized NumPy callables and scalar-only Python callables (automatically falling back to element-wise evaluation for arrays if a scalar-only callable is provided).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable[[float | ndarray], float | ndarray]
|
Function evaluated on local segment time \(\tau \in [0, \Delta t]\). |
required |
duration
|
float
|
Segment duration in seconds (\(\Delta t > 0\)). |
required |
event_times
|
Sequence[float]
|
Optional interior discontinuity timestamps in local time |
()
|
Source code in src/softpotato/techniques/waveforms.py
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 | |
ConstantSegment
¶
Bases: WaveformSegment
Constant-value hold segment \(y(\tau) = y_0\) for \(\tau \in [0, \Delta t]\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
float
|
Constant excitation level (potential in V or current in A). |
required |
duration
|
float
|
Hold duration in seconds (\(\Delta t > 0\)). |
required |
Source code in src/softpotato/techniques/waveforms.py
CustomWaveform
¶
Bases: BaseTechnique
Composite electrochemical waveform chaining arbitrary WaveformSegment objects.
Aggregates total duration and interior event_times across all
chained segments automatically. At interior segment boundaries, evaluation is
right-continuous (t in [t_k, t_{k+1}) evaluates segment k), while the
final endpoint t == duration evaluates the last segment at its end time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
segments
|
Sequence[WaveformSegment]
|
Non-empty ordered sequence of |
required |
mode
|
('potentiostatic', 'galvanostatic')
|
Control mode of the composite excitation signal. |
'potentiostatic'
|
n_points
|
int
|
Default number of points for |
None
|
Examples:
>>> from softpotato.techniques import (
... ConstantSegment,
... CustomWaveform,
... LinearRampSegment,
... )
>>> wf = CustomWaveform([
... ConstantSegment(0.0, duration=1.0),
... LinearRampSegment(0.0, -0.5, duration=2.0),
... ConstantSegment(-0.5, duration=1.0),
... ])
>>> wf.duration
4.0
>>> wf.event_times
(1.0, 3.0)
>>> wf(2.0)
-0.25
Source code in src/softpotato/techniques/waveforms.py
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 | |
LinearRampSegment
¶
Bases: WaveformSegment
Linear ramp segment from start to end over duration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start
|
float
|
Starting excitation value at \(\tau = 0\). |
required |
end
|
float
|
Ending excitation value at \(\tau = \Delta t\). |
required |
duration
|
float
|
Ramp duration in seconds (\(\Delta t > 0\)). Mutually exclusive
with |
None
|
rate
|
float
|
Positive ramp rate magnitude \(|dy/dt| > 0\). When given, duration
is computed as \(|y_{\text{end}} - y_{\text{start}}| / \text{rate}\).
Requires |
None
|
Source code in src/softpotato/techniques/waveforms.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | |
SinusoidalSegment
¶
Bases: WaveformSegment
Sinusoidal excitation segment over \(\tau \in [0, \Delta t]\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offset
|
float
|
DC offset level \(y_0\). |
required |
amplitude
|
float
|
Peak oscillation amplitude \(A\) (must be finite; typically |
required |
frequency
|
float
|
Oscillation frequency \(f > 0\) in Hz. |
required |
duration
|
float
|
Segment duration in seconds (\(\Delta t > 0\)). |
required |
phase
|
float
|
Initial phase angle \(\phi\) in radians. |
0.0
|
Source code in src/softpotato/techniques/waveforms.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | |
WaveformSegment
¶
Bases: ABC
Abstract base class for a single time-localized waveform segment.
A segment is defined over local time \(\tau \in [0, \Delta t]\) with
strictly positive duration \(\Delta t > 0\). Segments can be chained
sequentially inside CustomWaveform.
Source code in src/softpotato/techniques/waveforms.py
event_times
property
¶
Optional interior event timestamps in local time (0, duration).
start_value
property
¶
Excitation value at the start of the segment (\(\tau = 0\)).
end_value
property
¶
Excitation value at the end of the segment (\(\tau = \Delta t\)).
__call__
¶
resolve_plot_kind
¶
Resolve a concise plot key or verbose alias to its canonical plot kind.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
str
|
Concise plot key (e.g., |
required |
Returns:
| Type | Description |
|---|---|
str
|
Canonical plot key if recognized, otherwise the stripped input string. |
Source code in src/softpotato/techniques/base.py
analyze_cottrell
¶
analyze_cottrell(result: TechniqueResult | ArrayLike, current: ArrayLike | None = None, *, n: float, area: float, c_bulk: float, t_min: float | None = None, t_max: float | None = None, method: Literal['linear', 'nonlinear'] = 'linear', fit_background: bool = False, confidence_level: float = 0.95) -> CottrellFitResult
Perform Cottrell analysis (\(I\) vs. \(t^{-1/2}\)) on a CA transient.
Filters the transient to strictly positive times within [t_min, t_max]
and delegates to fit_cottrell to
recover the diffusion coefficient \(D\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
TechniqueResult or array - like
|
A chronoamperometric |
required |
current
|
array - like
|
1D Faradaic current array \(I\) in Amperes when |
None
|
n
|
float
|
Number of electrons transferred (\(n > 0\)). |
required |
area
|
float
|
Electrode surface area \(A > 0\) in \(\text{m}^2\) or \(\text{cm}^2\). |
required |
c_bulk
|
float
|
Bulk reactant concentration \(c^* > 0\) in matching volume units. |
required |
t_min
|
float
|
Lower time cutoff in seconds (inclusive, strictly positive). |
None
|
t_max
|
float
|
Upper time cutoff in seconds (inclusive). |
None
|
method
|
('linear', 'nonlinear')
|
Regression method forwarded to |
'linear'
|
fit_background
|
bool
|
Whether to fit a constant background current offset \(I_{\text{bg}}\). |
False
|
confidence_level
|
float
|
Confidence level for Student's \(t\) parameter intervals. |
0.95
|
Returns:
| Type | Description |
|---|---|
CottrellFitResult
|
Extracted diffusion coefficient \(D\), standard error, slope, background current, and goodness-of-fit statistics. |
Source code in src/softpotato/techniques/diagnostics.py
1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 | |
analyze_koutecky_levich
¶
analyze_koutecky_levich(results: RDESweepResult | Sequence[TechniqueResult] | Mapping[Any, TechniqueResult] | ArrayLike, currents: ArrayLike | None = None, *, potential: float | None = None, n: float, area: float, c_bulk: float, kinematic_viscosity: float | None = None, method: Literal['linear', 'nonlinear'] = 'linear', confidence_level: float = 0.95) -> KouteckyLevichFitResult
Perform Koutecký–Levich regression (\(|I|^{-1}\) vs. \(\omega^{-1/2}\)).
Evaluates \(I(E, \omega)\) at the chosen electrode potential across a
series of RDE sweeps (or accepts raw (omegas, currents) arrays) and
delegates to fit_koutecky_levich to
separate kinetic current \(I_K\) and mass-transport Levich constant
\(B\). Handles both anodic (\(I > 0\)) and cathodic (\(I < 0\))
IUPAC currents cleanly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
RDESweepResult, Sequence[TechniqueResult], Mapping, or array-like
|
Multi-rotation-rate RDE simulation results or 1D array of angular
rotation velocities \(\omega\) in rad/s (paired with |
required |
currents
|
array - like
|
1D array of Faradaic currents \(I\) in Amperes at each rotation rate
when |
None
|
potential
|
float
|
Electrode potential \(E\) in Volts at which to evaluate
\(I(E, \omega)\) across RDE sweeps. Required when |
None
|
n
|
float
|
Number of electrons transferred (\(n > 0\)). |
required |
area
|
float
|
Disk electrode surface area \(A > 0\) in \(\text{m}^2\) or \(\text{cm}^2\). |
required |
c_bulk
|
float
|
Bulk reactant concentration \(c^* > 0\) in matching volume units. |
required |
kinematic_viscosity
|
float
|
Electrolyte kinematic viscosity \(\nu > 0\). Inferred from RDE
technique metadata when available, defaulting to |
None
|
method
|
('linear', 'nonlinear')
|
Regression method forwarded to |
'linear'
|
confidence_level
|
float
|
Confidence level for Student's \(t\) parameter intervals. |
0.95
|
Returns:
| Type | Description |
|---|---|
KouteckyLevichFitResult
|
Extracted kinetic current \(I_K\), apparent rate constant \(k(E)\), Levich constant \(B\), diffusion coefficient \(D\), and goodness-of-fit statistics. |
Source code in src/softpotato/techniques/diagnostics.py
1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 | |
analyze_levich
¶
analyze_levich(results: RDESweepResult | Sequence[TechniqueResult] | Mapping[Any, TechniqueResult] | ArrayLike, limiting_currents: ArrayLike | None = None, *, n: float, area: float, c_bulk: float, kinematic_viscosity: float | None = None, limiting_potential: float | None = None, method: Literal['linear', 'nonlinear'] = 'linear', fit_intercept: bool = False, confidence_level: float = 0.95) -> LevichFitResult
Perform Levich regression (\(I_L\) vs. \(\omega^{1/2}\)) on RDE sweeps.
Accepts an RDESweepResult, a sequence or
mapping of RDE TechniqueResult objects, or
raw (omegas, limiting_currents) arrays, and delegates to
fit_levich.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
RDESweepResult, Sequence[TechniqueResult], Mapping, or array-like
|
Multi-rotation-rate RDE simulation results or 1D array of angular
rotation velocities \(\omega\) in rad/s (paired with
|
required |
limiting_currents
|
array - like
|
1D array of limiting currents \(I_L\) in Amperes when |
None
|
n
|
float
|
Number of electrons transferred (\(n > 0\)). |
required |
area
|
float
|
Disk electrode surface area \(A > 0\) in \(\text{m}^2\) or \(\text{cm}^2\). |
required |
c_bulk
|
float
|
Bulk reactant concentration \(c^* > 0\) in matching volume units. |
required |
kinematic_viscosity
|
float
|
Electrolyte kinematic viscosity \(\nu > 0\) in
\(\text{m}^2/\text{s}\) or \(\text{cm}^2/\text{s}\). If omitted,
inferred from the RDE technique metadata when available, defaulting to
|
None
|
limiting_potential
|
float
|
Optional electrode potential (in Volts) at which to sample \(I_L\)
from each RDE sweep. When |
None
|
method
|
('linear', 'nonlinear')
|
Regression method forwarded to |
'linear'
|
fit_intercept
|
bool
|
Whether to include a non-zero current offset intercept. |
False
|
confidence_level
|
float
|
Confidence level for Student's \(t\) parameter intervals. |
0.95
|
Returns:
| Type | Description |
|---|---|
LevichFitResult
|
Extracted Levich constant \(B\), diffusion coefficient \(D\), standard errors, and goodness-of-fit statistics. |
Source code in src/softpotato/techniques/diagnostics.py
997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 | |
analyze_nicholson
¶
analyze_nicholson(result: TechniqueResult | ArrayLike | float, current: ArrayLike | None = None, *, D: float, scan_rate: float | None = None, n: float = 1, temperature: float = STANDARD_TEMPERATURE, alpha: float = 0.5, cycle: int | None = -1, parabolic: bool = True, method: Literal['swaddle', 'lavagnini', 'table'] = 'swaddle') -> NicholsonDiagnostics
Extract heterogeneous rate constant \(k^0\) via Nicholson analysis.
Detects the anodic and cathodic peaks of a CV trace, computes
\(\Delta E_p = |E_{pa} - E_{pc}|\), evaluates the Nicholson kinetic
parameter \(\Psi\) and standard rate constant \(k^0\) via
nicholson_psi, and classifies the
kinetic regime via matsuda_ayabe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
TechniqueResult, array-like, or float
|
A CV |
required |
current
|
array - like
|
1D Faradaic current array in Amperes when |
None
|
D
|
float
|
Diffusion coefficient (\(D > 0\)). |
required |
scan_rate
|
float
|
Potential scan rate \(v > 0\) in V/s. Inferred automatically from
|
None
|
n
|
float
|
Number of electrons transferred (\(n > 0\)). |
1
|
temperature
|
float
|
Absolute temperature \(T > 0\) in Kelvin. |
298.15
|
alpha
|
float
|
Charge-transfer coefficient \(0 < \alpha < 1\) forwarded to
|
0.5
|
cycle
|
int or None
|
CV cycle index to inspect when |
-1
|
parabolic
|
bool
|
Whether to use 3-point parabolic interpolation for peak refinement. |
True
|
method
|
('swaddle', 'lavagnini', 'table')
|
Nicholson working curve approximation passed to |
'swaddle'
|
Returns:
| Type | Description |
|---|---|
NicholsonDiagnostics
|
Container with \(\Delta E_p\), \(\Psi\), \(k^0\), \(\Lambda\), Matsuda–Ayabe regime classification, and detected peaks. |
Source code in src/softpotato/techniques/diagnostics.py
854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 | |
analyze_randles_sevcik
¶
analyze_randles_sevcik(results: Sequence[TechniqueResult] | Mapping[Any, TechniqueResult] | ArrayLike, peak_currents: ArrayLike | None = None, *, n: float, area: float, c_bulk: float, temperature: float = STANDARD_TEMPERATURE, polarity: PeakPolarity = 'cathodic', cycle: int | None = -1, parabolic: bool = True, method: Literal['linear', 'nonlinear'] = 'linear', model: Literal['reversible', 'irreversible'] = 'reversible', alpha: float = 0.5, n_alpha: float = 1, fit_intercept: bool = True, confidence_level: float = 0.95) -> RandlesSevcikFitResult
Perform multi-scan-rate Randles–Ševčík regression to extract diffusivity \(D\).
Extracts peak currents \(I_p\) and scan rates \(v\) from a series of
CV or LSV TechniqueResult objects (or accepts
raw (scan_rates, peak_currents) arrays directly) and delegates to
fit_randles_sevcik.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
Sequence[TechniqueResult], Mapping[Any, TechniqueResult], or array-like
|
Collection of CV/LSV simulation results (e.g., from
|
required |
peak_currents
|
array - like
|
1D array of peak currents \(I_p\) in Amperes when |
None
|
n
|
float
|
Number of electrons transferred (\(n > 0\)). |
required |
area
|
float
|
Electrode surface area \(A > 0\) in \(\text{m}^2\) or \(\text{cm}^2\). |
required |
c_bulk
|
float
|
Bulk reactant concentration \(c^* > 0\) in matching volume units. |
required |
temperature
|
float
|
Absolute temperature \(T > 0\) in Kelvin. |
298.15
|
polarity
|
('cathodic', 'anodic')
|
Peak polarity to extract from each voltammogram. |
'cathodic'
|
cycle
|
int or None
|
CV cycle index to inspect (ignored for LSV or raw arrays). |
-1
|
parabolic
|
bool
|
Whether to use parabolic sub-sample peak refinement. |
True
|
method
|
('linear', 'nonlinear')
|
Regression method passed to |
'linear'
|
model
|
('reversible', 'irreversible')
|
Reversibility model passed to |
'reversible'
|
alpha
|
float
|
Charge-transfer coefficient for irreversible model. |
0.5
|
n_alpha
|
float
|
Electrons transferred up to the rate-determining step (irreversible model). |
1
|
fit_intercept
|
bool
|
Whether to fit a non-zero current intercept. |
True
|
confidence_level
|
float
|
Confidence level for Student's \(t\) parameter intervals. |
0.95
|
Returns:
| Type | Description |
|---|---|
RandlesSevcikFitResult
|
Fitted diffusion coefficient \(D\), slope, intercept, standard errors, and goodness-of-fit metrics. |
Source code in src/softpotato/techniques/diagnostics.py
706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 | |
analyze_sand
¶
analyze_sand(result: TechniqueResult | ArrayLike, signal: ArrayLike | None = None, *, n: float, area: float, c_bulk: float, threshold: float = 0.001, D: float | None = None, current: float | None = None, species: str | None = None, signal_kind: Literal['auto', 'concentration', 'potential'] = 'auto', relative: bool = True, F: float = FARADAY) -> SandDiagnostics
Detect chronopotentiometric transition time \(\tau\) and run Sand analysis.
Detects the transition time \(\tau\) from reactant surface concentration
depletion (via detect_transition_time)
or from the potential inflection point \(\max |dE/dt|\), computes the
experimental Sand product \(|I|\sqrt{\tau}\) and estimated diffusion
coefficient \(D\), and optionally compares against
sand_transition_time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
TechniqueResult or array - like
|
A chronopotentiometric |
required |
signal
|
array - like
|
1D surface concentration \(c(0, t)\) or electrode potential
\(E(t)\) array when |
None
|
n
|
float
|
Number of electrons transferred (\(n > 0\)). |
required |
area
|
float
|
Electrode surface area \(A > 0\) in \(\text{m}^2\) or \(\text{cm}^2\). |
required |
c_bulk
|
float
|
Bulk reactant concentration \(c^* > 0\) in matching volume units. |
required |
threshold
|
float
|
Surface concentration depletion threshold forwarded to
|
1e-3
|
D
|
float
|
Known diffusion coefficient (\(D > 0\)) for computing theoretical Sand transition time \(\tau_{\text{th}}\) and relative error. |
None
|
current
|
float
|
Applied constant current \(I \neq 0\) in Amperes. Inferred
automatically from |
None
|
species
|
str
|
Reactant species name to inspect in |
None
|
signal_kind
|
('auto', 'concentration', 'potential')
|
Signal source used for transition time detection. |
'auto'
|
relative
|
bool
|
Whether |
True
|
F
|
float
|
Faraday constant in \(\text{C}/\text{mol}\). |
FARADAY
|
Returns:
| Type | Description |
|---|---|
SandDiagnostics
|
Detected \(\tau\), theoretical \(\tau\) (if |
Source code in src/softpotato/techniques/diagnostics.py
1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 | |
analyze_tafel
¶
analyze_tafel(result: TechniqueResult | ArrayLike, current: ArrayLike | None = None, *, E0: float, overpotential_window: tuple[float, float] | None = None, branch: PeakPolarity = 'cathodic', temperature: float = STANDARD_TEMPERATURE, n: float = 1, area: float | None = None, c_bulk: float | None = None, cycle: int | None = -1, confidence_level: float = 0.95) -> TafelFitResult
Extract Tafel slope, transfer coefficient, and exchange current.
Computes overpotential \(\eta = E - E^{0\prime}\) and delegates to
fit_tafel on the selected kinetic
branch ('cathodic' for \(\eta < 0\), 'anodic' for \(\eta > 0\)).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
TechniqueResult or array - like
|
A voltammetric |
required |
current
|
array - like
|
1D Faradaic current array \(I\) in Amperes when |
None
|
E0
|
float
|
Formal / equilibrium potential \(E^{0\prime}\) in Volts used to compute \(\eta = E - E^{0\prime}\). |
required |
overpotential_window
|
tuple of (float, float)
|
Signed overpotential interval |
None
|
branch
|
('cathodic', 'anodic')
|
Kinetic polarization branch to fit. |
'cathodic'
|
temperature
|
float
|
Absolute temperature \(T > 0\) in Kelvin. |
298.15
|
n
|
float
|
Number of electrons transferred (\(n > 0\)). |
1
|
area
|
float
|
Electrode surface area \(A > 0\) (if provided alongside |
None
|
c_bulk
|
float
|
Bulk concentration \(c^* > 0\) (if provided alongside |
None
|
cycle
|
int or None
|
CV cycle index to inspect when |
-1
|
confidence_level
|
float
|
Confidence level for Student's \(t\) parameter intervals. |
0.95
|
Returns:
| Type | Description |
|---|---|
TafelFitResult
|
Extracted exchange current \(I_0\), Tafel slope \(b\) (in V/dec and mV/dec), charge-transfer coefficient \(\alpha\), optional \(k^0\), and goodness-of-fit statistics. |
Source code in src/softpotato/techniques/diagnostics.py
1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 | |
find_peaks
¶
find_peaks(result_or_E: TechniqueResult | ArrayLike, current: ArrayLike | None = None, *, cycle: int | None = -1, parabolic: bool = True, prominence: float | None = None, min_current: float = 0.0, distance: int | None = None, polarity: Literal['both', 'anodic', 'cathodic'] = 'both', return_all: Literal[False] = False) -> CVDiagnostics
find_peaks(result_or_E: TechniqueResult | ArrayLike, current: ArrayLike | None = None, *, cycle: int | None = -1, parabolic: bool = True, prominence: float | None = None, min_current: float = 0.0, distance: int | None = None, polarity: Literal['both', 'anodic', 'cathodic'] = 'both', return_all: Literal[True]) -> list[PeakInfo]
find_peaks(result_or_E: TechniqueResult | ArrayLike, current: ArrayLike | None = None, *, cycle: int | None = -1, parabolic: bool = True, prominence: float | None = None, min_current: float = 0.0, distance: int | None = None, polarity: Literal['both', 'anodic', 'cathodic'] = 'both', return_all: bool = False) -> CVDiagnostics | list[PeakInfo]
Detect anodic and cathodic voltammetric peaks under IUPAC polarity conventions.
Identifies interior local maxima (\(I > 0\), anodic) and local minima (\(I < 0\), cathodic) in a voltammogram, optionally refining peak potential \(E_p\) and peak current \(I_p\) via 3-point parabolic interpolation and computing the rising-flank half-peak potential \(E_{p/2}\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result_or_E
|
TechniqueResult or array - like
|
Either a |
required |
current
|
array - like
|
1D array of Faradaic currents \(I\) in Amperes (required when
|
None
|
cycle
|
int or None
|
Cycle index to analyze when |
-1
|
parabolic
|
bool
|
If |
True
|
prominence
|
float
|
Minimum peak prominence (in Amperes) forwarded to
|
None
|
min_current
|
float
|
Minimum absolute current threshold (\(|I_p| > \text{min\_current}\)) for a peak to be accepted. |
0.0
|
distance
|
int
|
Minimum sample separation between adjacent peaks of the same polarity. |
None
|
polarity
|
('both', 'anodic', 'cathodic')
|
Which peak polarities to search for. |
'both'
|
return_all
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
CVDiagnostics or list[PeakInfo]
|
Voltammetric peak diagnostics summary or full list of detected peaks. |
Source code in src/softpotato/techniques/diagnostics.py
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 | |
simulate
¶
simulate(technique: BaseTechnique, mechanism: MechanismInput, geometry: Geometry | str = 'planar', grid: ndarray | Mesh1D | None = None, solver: BaseSolver | str = 'scipy_ivp', t_eval: ndarray | Sequence[float] | None = None, solver_kwargs: Mapping[str, Any] | None = None, *, mesh_kwargs: Mapping[str, Any] | None = None, bc_kwargs: Mapping[str, Any] | None = None, bc_overrides: Mapping[str, tuple[BoundaryCondition, BoundaryCondition]] | None = None, electrodes: Literal['left', 'right', 'both'] = 'left', bulk_bc: Literal['dirichlet', 'neumann'] = 'dirichlet', n_electrons: int | Mapping[str, int] | None = None, kinetics: HeterogeneousKinetics | NernstianEquilibrium | None = None) -> TechniqueResult
Run a complete electrochemical technique simulation in a single call.
Orchestrates physics-informed spatial meshing, boundary condition assembly (both potentiostatic and galvanostatic), event-aware piecewise numerical integration across waveform discontinuities/switching vertices, and Faradaic current / cumulative charge extraction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
technique
|
BaseTechnique
|
Electrochemical excitation waveform (e.g., |
required |
mechanism
|
Mechanism, SpeciesCollection, Sequence[Species], or Species
|
Chemical/electrochemical reaction mechanism or species specification.
When a |
required |
geometry
|
Geometry or str
|
Coordinate geometry instance or registered alias ( |
`'planar'`
|
grid
|
ndarray or Mesh1D
|
1D spatial grid or mesh. When |
None
|
solver
|
BaseSolver or str
|
Numerical diffusion solver instance or registered alias ( |
`'scipy_ivp'`
|
t_eval
|
ndarray or Sequence[float]
|
Strictly increasing 1D evaluation timestamps in |
None
|
solver_kwargs
|
Mapping[str, Any]
|
Optional keyword arguments passed to the solver (e.g. |
None
|
mesh_kwargs
|
Mapping[str, Any]
|
Optional keyword arguments forwarded to |
None
|
bc_kwargs
|
Mapping[str, Any]
|
Optional keyword arguments forwarded to |
None
|
bc_overrides
|
Mapping[str, tuple[BoundaryCondition, BoundaryCondition]]
|
Optional per-species boundary condition overrides. |
None
|
electrodes
|
('left', 'right', 'both')
|
Active electrode boundary for Faradaic current evaluation. |
'left'
|
bulk_bc
|
('dirichlet', 'neumann')
|
Boundary condition type applied at the bulk (non-electrode) boundary. |
'dirichlet'
|
n_electrons
|
int or Mapping[str, int]
|
Optional electron transfer count overrides. |
None
|
kinetics
|
HeterogeneousKinetics or NernstianEquilibrium
|
Optional interfacial kinetics used when |
None
|
Returns:
| Type | Description |
|---|---|
TechniqueResult
|
Structured simulation result containing |
Source code in src/softpotato/techniques/pipeline.py
601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 | |
simulate_sweep
¶
simulate_sweep(techniques: Sequence[BaseTechnique], mechanism: MechanismInput, *, values: None = None, geometry: Geometry | str = 'planar', grid: ndarray | Mesh1D | None = None, solver: BaseSolver | str = 'scipy_ivp', t_eval: ndarray | Sequence[float] | None = None, solver_kwargs: Mapping[str, Any] | None = None, **kwargs: Any) -> list[TechniqueResult]
simulate_sweep(techniques: Mapping[Any, BaseTechnique], mechanism: MechanismInput, *, values: None = None, geometry: Geometry | str = 'planar', grid: ndarray | Mesh1D | None = None, solver: BaseSolver | str = 'scipy_ivp', t_eval: ndarray | Sequence[float] | None = None, solver_kwargs: Mapping[str, Any] | None = None, **kwargs: Any) -> dict[Any, TechniqueResult]
simulate_sweep(techniques: Callable[[Any], BaseTechnique], mechanism: MechanismInput, *, values: Sequence[Any], geometry: Geometry | str = 'planar', grid: ndarray | Mesh1D | None = None, solver: BaseSolver | str = 'scipy_ivp', t_eval: ndarray | Sequence[float] | None = None, solver_kwargs: Mapping[str, Any] | None = None, **kwargs: Any) -> dict[Any, TechniqueResult]
simulate_sweep(techniques: Sequence[BaseTechnique] | Mapping[Any, BaseTechnique] | Callable[[Any], BaseTechnique], mechanism: MechanismInput, *, values: Sequence[Any] | None = None, geometry: Geometry | str = 'planar', grid: ndarray | Mesh1D | None = None, solver: BaseSolver | str = 'scipy_ivp', t_eval: ndarray | Sequence[float] | None = None, solver_kwargs: Mapping[str, Any] | None = None, **kwargs: Any) -> list[TechniqueResult] | dict[Any, TechniqueResult]
Run a parameter sweep (e.g., scan-rate or rotation-rate series) via simulate.
Supports three input modes:
- Sequence of techniques:
simulate_sweep([cv1, cv2, ...], mechanism)returnslist[TechniqueResult]. - Mapping of parameter labels to techniques:
simulate_sweep({0.05: cv1, 0.1: cv2}, mechanism)returnsdict[Any, TechniqueResult]. - Factory callable + parameter values:
simulate_sweep(lambda v: CyclicVoltammetry(..., scan_rate=v), mechanism, values=[0.05, 0.1, 0.5])returnsdict[Any, TechniqueResult]keyed by each value invalues.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
techniques
|
Sequence[BaseTechnique], Mapping[Any, BaseTechnique], or Callable
|
Collection of techniques to simulate or a factory callable mapping each
parameter value in |
required |
mechanism
|
Mechanism, SpeciesCollection, Sequence[Species], or Species
|
Chemical/electrochemical mechanism passed to |
required |
values
|
Sequence[Any]
|
Parameter values to sweep when |
None
|
geometry
|
Geometry or str
|
Coordinate geometry forwarded to |
`'planar'`
|
grid
|
ndarray or Mesh1D
|
Optional fixed spatial grid forwarded to |
None
|
solver
|
BaseSolver or str
|
Numerical solver forwarded to |
`'scipy_ivp'`
|
t_eval
|
ndarray or Sequence[float]
|
Optional fixed evaluation timestamps forwarded to |
None
|
solver_kwargs
|
Mapping[str, Any]
|
Optional solver options forwarded to |
None
|
**kwargs
|
Any
|
Additional keyword arguments forwarded to |
{}
|
Returns:
| Type | Description |
|---|---|
list[TechniqueResult] or dict[Any, TechniqueResult]
|
Ordered list or mapping of simulation results ready for diagnostics. |
Source code in src/softpotato/techniques/pipeline.py
1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 | |
plot_charge_vs_time
¶
plot_charge_vs_time(result: TechniqueResult, *, ax: Axes | None = None, step: int | None = None, title: str | None = None, xlabel: str | None = None, ylabel: str | None = None, grid: bool = True, figsize: tuple[float, float] | None = None, **plot_kwargs: Any) -> tuple[Figure, Axes]
Plot cumulative Faradaic charge vs. time (\(Q(t)\) vs. \(t\)).
Source code in src/softpotato/techniques/plotting.py
plot_concentration_profile
¶
plot_concentration_profile(result: TechniqueResult, *, t: float | Sequence[float] | None = None, species: str | Sequence[str] | None = None, step: int | None = None, ax: Axes | None = None, title: str | None = None, xlabel: str | None = None, ylabel: str | None = None, grid: bool = True, figsize: tuple[float, float] | None = None, **plot_kwargs: Any) -> tuple[Figure, Axes]
Plot species concentration vs. spatial distance at specific time(s).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
TechniqueResult
|
Simulation result containing spatial concentration profiles. |
required |
t
|
float or Sequence[float]
|
Target timestamp(s) in seconds. Defaults to the final simulated time
|
None
|
species
|
str or Sequence[str]
|
Species name(s) to plot. Defaults to all species in |
None
|
step
|
int
|
For |
None
|
ax
|
Axes
|
Existing Axes to draw onto. |
None
|
title
|
str
|
Optional overrides for the default |
None
|
xlabel
|
str
|
Optional overrides for the default |
None
|
ylabel
|
str
|
Optional overrides for the default |
None
|
grid
|
bool
|
Whether to show a light background grid. |
True
|
figsize
|
tuple[float, float]
|
Figure size passed to |
None
|
**plot_kwargs
|
Any
|
Additional keyword arguments forwarded to |
{}
|
Returns:
| Type | Description |
|---|---|
tuple[Figure, Axes]
|
Figure and Axes containing the concentration profile(s). |
Source code in src/softpotato/techniques/plotting.py
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 | |
plot_cottrell
¶
plot_cottrell(result_or_t: TechniqueResult | ArrayLike, fit_result: CottrellFitResult, *, current: ArrayLike | None = None, t_min: float | None = None, t_max: float | None = None, ax: Axes | None = None, title: str | None = None, grid: bool = True, figsize: tuple[float, float] | None = None) -> tuple[Figure, Axes]
Plot a Cottrell diagnostic regression (\(I\) vs. \(t^{-1/2}\)).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result_or_t
|
TechniqueResult or array - like
|
Chronoamperometry |
required |
fit_result
|
CottrellFitResult
|
Fit output from |
required |
current
|
array - like
|
Optional raw current array when |
None
|
t_min
|
float
|
Time window bounds matching those passed to |
None
|
t_max
|
float
|
Time window bounds matching those passed to |
None
|
ax
|
Axes
|
Existing Axes to draw onto. |
None
|
title
|
str
|
Optional plot title override. |
None
|
grid
|
bool
|
Whether to display a background grid. |
True
|
figsize
|
tuple[float, float]
|
Figure size when |
None
|
Returns:
| Type | Description |
|---|---|
tuple[Figure, Axes]
|
Figure and Axes containing the Cottrell plot. |
Source code in src/softpotato/techniques/plotting.py
1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 | |
plot_current_vs_time
¶
plot_current_vs_time(result: TechniqueResult, *, ax: Axes | None = None, step: int | None = None, title: str | None = None, xlabel: str | None = None, ylabel: str | None = None, grid: bool = True, figsize: tuple[float, float] | None = None, **plot_kwargs: Any) -> tuple[Figure, Axes]
Plot net Faradaic current vs. time (\(I(t)\) vs. \(t\)).
Handles both 1D current arrays and 2D SampledCurrentVoltammetry
step families (using step to select a single step or plotting all steps).
Source code in src/softpotato/techniques/plotting.py
plot_dpv
¶
plot_dpv(result: TechniqueResult, *, ax: Axes | None = None, show_components: bool = False, title: str | None = None, xlabel: str | None = None, ylabel: str | None = None, grid: bool = True, figsize: tuple[float, float] | None = None, **plot_kwargs: Any) -> tuple[Figure, Axes]
Plot a Differential Pulse Voltammogram (\(\Delta I\) vs. \(E_{\mathrm{base}}\)).
Source code in src/softpotato/techniques/plotting.py
plot_koutecky_levich
¶
plot_koutecky_levich(results_or_omega: RDESweepResult | Sequence[TechniqueResult] | Mapping[Any, TechniqueResult] | ArrayLike, fit_result: KouteckyLevichFitResult, *, currents: ArrayLike | None = None, potential: float | None = None, ax: Axes | None = None, title: str | None = None, grid: bool = True, figsize: tuple[float, float] | None = None) -> tuple[Figure, Axes]
Plot a Koutecký–Levich diagnostic regression (\(I^{-1}\) vs. \(\omega^{-1/2}\)).
Source code in src/softpotato/techniques/plotting.py
plot_levich
¶
plot_levich(results_or_omega: RDESweepResult | Sequence[TechniqueResult] | Mapping[Any, TechniqueResult] | ArrayLike, fit_result: LevichFitResult, *, currents: ArrayLike | None = None, ax: Axes | None = None, title: str | None = None, grid: bool = True, figsize: tuple[float, float] | None = None) -> tuple[Figure, Axes]
Plot a Levich RDE diagnostic regression (\(I_L\) vs. \(\omega^{1/2}\)).
Source code in src/softpotato/techniques/plotting.py
plot_peaks
¶
plot_peaks(result: TechniqueResult, peaks: CVDiagnostics | PeakInfo | Sequence[PeakInfo] | None = None, *, cycle: int | None = -1, ax: Axes | None = None, title: str | None = None, grid: bool = True, figsize: tuple[float, float] | None = None, **plot_kwargs: Any) -> tuple[Figure, Axes]
Plot a voltammogram with annotated anodic and cathodic peak diagnostics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
TechniqueResult
|
Voltammetric simulation result (CV, LSV, SWV, DPV). |
required |
peaks
|
CVDiagnostics, PeakInfo, or Sequence[PeakInfo]
|
Pre-computed peak diagnostics from |
None
|
cycle
|
int or None
|
Cycle index for |
-1
|
ax
|
Axes
|
Existing Axes to draw onto. |
None
|
title
|
str
|
Optional title override. When |
None
|
grid
|
bool
|
Whether to display a grid. |
True
|
figsize
|
tuple[float, float]
|
Figure size when |
None
|
**plot_kwargs
|
Any
|
Additional keyword arguments forwarded to |
{}
|
Returns:
| Type | Description |
|---|---|
tuple[Figure, Axes]
|
Figure and Axes with the voltammogram and peak markers. |
Source code in src/softpotato/techniques/plotting.py
plot_potential_vs_time
¶
plot_potential_vs_time(result: TechniqueResult, *, ax: Axes | None = None, step: int | None = None, show_transition_time: bool = True, title: str | None = None, xlabel: str | None = None, ylabel: str | None = None, grid: bool = True, figsize: tuple[float, float] | None = None, **plot_kwargs: Any) -> tuple[Figure, Axes]
Plot electrode potential vs. time (\(E(t)\) vs. \(t\)).
For Chronopotentiometry, optionally marks the detected transition
time \(\tau\) with a vertical dashed reference line when
show_transition_time=True.
Source code in src/softpotato/techniques/plotting.py
plot_randles_sevcik
¶
plot_randles_sevcik(results_or_v: Sequence[TechniqueResult] | Mapping[Any, TechniqueResult] | ArrayLike, fit_result: RandlesSevcikFitResult, *, peak_currents: ArrayLike | None = None, polarity: PeakPolarity = 'cathodic', cycle: int | None = -1, ax: Axes | None = None, title: str | None = None, grid: bool = True, figsize: tuple[float, float] | None = None) -> tuple[Figure, Axes]
Plot a Randles–Ševčík diagnostic regression (\(|I_p|\) vs. \(v^{1/2}\)).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results_or_v
|
Sequence[TechniqueResult], Mapping[Any, TechniqueResult], or array-like
|
Collection of CV/LSV results or raw 1D array of scan rates \(v\) (V/s). |
required |
fit_result
|
RandlesSevcikFitResult
|
Fit output from |
required |
peak_currents
|
array - like
|
Optional raw peak current array when |
None
|
polarity
|
('cathodic', 'anodic')
|
Peak polarity label used when extracting from |
'cathodic'
|
cycle
|
int or None
|
Unused placeholder for API parity with |
-1
|
ax
|
Axes
|
Existing Axes to draw onto. |
None
|
title
|
str
|
Optional plot title override. |
None
|
grid
|
bool
|
Whether to display a background grid. |
True
|
figsize
|
tuple[float, float]
|
Figure size when |
None
|
Returns:
| Type | Description |
|---|---|
tuple[Figure, Axes]
|
Figure and Axes containing the Randles–Ševčík plot. |
Source code in src/softpotato/techniques/plotting.py
1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 | |
plot_result
¶
plot_result(result: TechniqueResult, kind: str | None = None, *, ax: Axes | None = None, **kwargs: Any) -> tuple[Figure, Axes]
Dispatch a plot for result using the technique's declarative plot specs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
TechniqueResult
|
Output from |
required |
kind
|
str
|
Concise plot key (e.g. |
None
|
ax
|
Axes
|
Existing Axes to draw onto. |
None
|
**kwargs
|
Any
|
Additional keyword arguments forwarded to the plot renderer. |
{}
|
Returns:
| Type | Description |
|---|---|
tuple[Figure, Axes]
|
Figure and Axes containing the rendered plot. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
Source code in src/softpotato/techniques/plotting.py
plot_scv
¶
plot_scv(result: TechniqueResult, *, ax: Axes | None = None, sample_times: float | Sequence[float] | ndarray | None = None, title: str | None = None, xlabel: str | None = None, ylabel: str | None = None, grid: bool = True, figsize: tuple[float, float] | None = None, **plot_kwargs: Any) -> tuple[Figure, Axes]
Plot a Sampled-Current Voltammogram (\(I(\tau)\) vs. \(E_{\mathrm{step}}\)).
Source code in src/softpotato/techniques/plotting.py
plot_summary
¶
plot_summary(result: TechniqueResult, *, t: float | Sequence[float] | None = None, species: str | Sequence[str] | None = None, figsize: tuple[float, float] | None = None, **kwargs: Any) -> tuple[Figure, np.ndarray]
Render a multi-panel summary figure for a TechniqueResult.
Panels include the technique's default plot together with the universal
views ('i_vs_t', 'E_vs_t', 'c_vs_x'), deduplicated in order
(producing a 1x3 layout when the default plot is already 'i_vs_t' or
'E_vs_t', or a 2x2 layout otherwise).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
TechniqueResult
|
Simulation result to summarize. |
required |
t
|
float or Sequence[float]
|
Target time(s) in seconds passed to the |
None
|
species
|
str or Sequence[str]
|
Species subset passed to the |
None
|
figsize
|
tuple[float, float]
|
Optional figure size override. |
None
|
**kwargs
|
Any
|
Additional keyword arguments forwarded to each panel's |
{}
|
Returns:
| Type | Description |
|---|---|
tuple[Figure, ndarray]
|
Figure and array of Axes objects. |
Source code in src/softpotato/techniques/plotting.py
plot_sweep
¶
plot_sweep(results: Sequence[TechniqueResult] | Mapping[Any, TechniqueResult] | RDESweepResult, kind: str | None = None, *, ax: Axes | None = None, labels: Sequence[str] | None = None, legend_title: str | None = None, figsize: tuple[float, float] | None = None, **kwargs: Any) -> tuple[Figure, Axes]
Overlay a series of simulation results on a single set of axes.
Accepts output from simulate_sweep (either
a Sequence[TechniqueResult] or Mapping[Any, TechniqueResult]) or
RDESweepResult.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
Sequence[TechniqueResult], Mapping[Any, TechniqueResult], or RDESweepResult
|
Collection of simulation results to overlay. |
required |
kind
|
str
|
Concise plot key or verbose alias. Defaults to the first result's
|
None
|
ax
|
Axes
|
Existing Axes to draw onto. |
None
|
labels
|
Sequence[str]
|
Custom legend labels matching the length of |
None
|
legend_title
|
str
|
Optional title for the legend. |
None
|
figsize
|
tuple[float, float]
|
Figure size passed to |
None
|
**kwargs
|
Any
|
Additional keyword arguments forwarded to |
{}
|
Returns:
| Type | Description |
|---|---|
tuple[Figure, Axes]
|
Figure and Axes containing the overlaid sweep traces. |
Source code in src/softpotato/techniques/plotting.py
843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 | |
plot_swv
¶
plot_swv(result: TechniqueResult, *, ax: Axes | None = None, show_components: bool = True, title: str | None = None, xlabel: str | None = None, ylabel: str | None = None, grid: bool = True, figsize: tuple[float, float] | None = None, **plot_kwargs: Any) -> tuple[Figure, Axes]
Plot a Square-Wave Voltammogram (\(I_{\mathrm{net}}\), \(I_f\), \(I_r\) vs. \(E_{\mathrm{step}}\)).
Source code in src/softpotato/techniques/plotting.py
plot_tafel
¶
plot_tafel(overpotential_or_result: TechniqueResult | ArrayLike, fit_result: TafelFitResult, *, current: ArrayLike | None = None, E0: float | None = None, overpotential_window: tuple[float, float] | None = None, branch: Literal['cathodic', 'anodic'] = 'cathodic', cycle: int | None = -1, ax: Axes | None = None, title: str | None = None, grid: bool = True, figsize: tuple[float, float] | None = None) -> tuple[Figure, Axes]
Plot a Tafel diagnostic regression (\(\eta\) vs. \(\log_{10}|I|\)).
Source code in src/softpotato/techniques/plotting.py
1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 | |
plot_voltammogram
¶
plot_voltammogram(result: TechniqueResult, *, ax: Axes | None = None, cycle: int | Literal['all'] | None = None, peaks: bool | CVDiagnostics | PeakInfo | Sequence[PeakInfo] | None = None, title: str | None = None, xlabel: str | None = None, ylabel: str | None = None, grid: bool = True, figsize: tuple[float, float] | None = None, **plot_kwargs: Any) -> tuple[Figure, Axes]
Plot Faradaic current vs. electrode potential (\(I\) vs. \(E\)).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
TechniqueResult
|
Simulation result to plot. |
required |
ax
|
Axes
|
Existing Axes to draw onto. |
None
|
cycle
|
int, 'all', or None
|
For |
None
|
peaks
|
bool, CVDiagnostics, PeakInfo, or Sequence[PeakInfo]
|
If |
None
|
title
|
str
|
Optional overrides for the default |
None
|
xlabel
|
str
|
Optional overrides for the default |
None
|
ylabel
|
str
|
Optional overrides for the default |
None
|
grid
|
bool
|
Whether to show a light background grid. |
True
|
figsize
|
tuple[float, float]
|
Figure size passed to |
None
|
**plot_kwargs
|
Any
|
Additional keyword arguments forwarded to |
{}
|
Returns:
| Type | Description |
|---|---|
tuple[Figure, Axes]
|
Figure and Axes containing the voltammogram. |
Source code in src/softpotato/techniques/plotting.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | |
simulate_rde_sweep
¶
simulate_rde_sweep(*, sweep: RDESweep | None = None, waveform: BaseTechnique | None = None, omegas: Sequence[float] | ArrayLike | None = None, rpms: Sequence[float] | ArrayLike | None = None, kinematic_viscosity: float = _DEFAULT_KINEMATIC_VISCOSITY, model: RDEModel = 'nernst_layer', E_start: float | None = None, E_end: float | None = None, scan_rate: float | None = None, dE: float | None = None, n_time_points: int | None = None, D: float | None = None, diffusivity: Mapping[str, float] | None = None, c_bulk: float = 1.0, initial_conditions: Mapping[str, Any] | None = None, boundary_conditions: Mapping[str, tuple[BoundaryCondition, BoundaryCondition]] | None = None, kinetics: HeterogeneousKinetics | NernstianEquilibrium | None = None, species_name: str = 'Ox', red_species_name: str = 'Red', c_red_bulk: float = 0.0, n_electrons: int | Mapping[str, int] = 1, area: float = 1.0, reactions: Any = None, n_points: int = 80, grid_kind: str = 'geometric', gamma: float = 1.06, beta: float = 3.0, domain_factor: float | None = None, solver: str = 'scipy_ivp', t_eval: ndarray | None = None, solver_kwargs: Mapping[str, Any] | None = None) -> RDESweepResult
Simulate a multi-rotation-rate RDE sweep for Levich or Koutecký–Levich analysis.
Accepts either a pre-configured RDESweep instance or direct sweep
parameters (omegas/rpms plus waveform or LSV parameters), builds
a rotation-rate-specific DiffusionProblem for
each speed, and solves all cases in a single call.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sweep
|
RDESweep
|
Pre-configured sweep object. If omitted, one is constructed from
|
None
|
waveform
|
BaseTechnique
|
Shared potentiostatic waveform (ignored if |
None
|
omegas
|
Sequence[float]
|
Rotation rates in rad/s or RPM (ignored if |
None
|
rpms
|
Sequence[float]
|
Rotation rates in rad/s or RPM (ignored if |
None
|
kinematic_viscosity
|
float
|
Electrolyte kinematic viscosity in \(\text{m}^2/\text{s}\). |
1e-6
|
model
|
('nernst_layer', 'convective_diffusion')
|
Hydrodynamic transport model. |
'nernst_layer'
|
D
|
float
|
Scalar diffusion coefficient \(D > 0\). Mutually exclusive with
|
None
|
diffusivity
|
Mapping[str, float]
|
Per-species diffusion coefficients. Mutually exclusive with |
None
|
c_bulk
|
float
|
Bulk concentration of the primary electroactive species. |
1.0
|
initial_conditions
|
Mapping[str, Any]
|
Optional explicit initial concentration profiles. |
None
|
boundary_conditions
|
Mapping[str, tuple[BoundaryCondition, BoundaryCondition]]
|
Optional explicit boundary conditions. |
None
|
kinetics
|
HeterogeneousKinetics or NernstianEquilibrium
|
Interfacial charge-transfer model used to generate boundary conditions
when |
None
|
species_name
|
str
|
Primary electroactive species name. |
'Ox'
|
red_species_name
|
str
|
Reduced partner species name (used when |
'Red'
|
c_red_bulk
|
float
|
Bulk concentration of the reduced partner species. |
0.0
|
n_electrons
|
int or Mapping[str, int]
|
Electrons transferred per species (matches |
1
|
area
|
float
|
Electrode geometric surface area. |
1.0
|
reactions
|
Any
|
Optional homogeneous reaction term. |
None
|
n_points
|
int
|
Number of spatial grid nodes per simulation. |
80
|
grid_kind
|
('geometric', 'exponential', 'uniform')
|
Mesh family passed to |
'geometric'
|
gamma
|
float
|
Geometric expansion ratio for |
1.06
|
beta
|
float
|
Stretching parameter for |
3.0
|
domain_factor
|
float
|
Override domain multiplier \(k\) applied to \(\delta_N\). |
None
|
solver
|
str
|
Registered solver name passed to |
'scipy_ivp'
|
t_eval
|
ndarray
|
Evaluation timestamps shared across all rotation rates. Defaults to
|
None
|
solver_kwargs
|
Mapping[str, Any]
|
Additional keyword arguments forwarded to |
None
|
Returns:
| Type | Description |
|---|---|
RDESweepResult
|
Aggregated rotation rates, per-rate solver results, and limiting currents suitable for Levich or Koutecký–Levich analysis. |
Source code in src/softpotato/techniques/rde.py
1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 | |