Pulsed electrochemical reactor
A stirred electrochemical reactor driven by current pulses.
- Class:
PulsedElectrochemicalReactorSystem - Import:
from skcomplex.systems.chemistry.kinetics import PulsedElectrochemicalReactorSystem - Field:
chemistry/kinetics - Topics:
ode,electrochemistry,pulses,driven - References:
- Trzaska 2023
- Bard and Faulkner 2001
Use this system
The block imports the class and simulates the system with its default parameters and its tuned run settings.
from skcomplex.systems.chemistry.kinetics import PulsedElectrochemicalReactorSystem
trajectory = PulsedElectrochemicalReactorSystem().prepare().simulate()
Parameters
The model parameters take these defaults, and set_params changes them.
| Parameter | Default |
|---|---|
eta |
0.0 |
c |
1.0 |
C |
1.0 |
alpha |
0.5 |
tau |
10.0 |
kappa |
0.05 |
current |
5.0 |
period |
10.0 |
width |
2.0 |
solver |
'auto' |
backend |
'auto' |
Tags
The system with its default parameters has these capability tags, which solvers and analyses check.
| Tag | Values |
|---|---|
| Time | continuous |
| Space | none |
| Laws | rate |
| Randomness | deterministic |
| Domains | real |
| Structure | fixed |
Class
The source of the class shows how it builds its components from its model parameters.
class PulsedElectrochemicalReactorSystem(BaseSystem):
"""A stirred electrochemical reactor driven by current pulses.
A train of current pulses drives its electrode.
Every pulse charges the double layer, the overpotential drives a Butler-Volmer current that consumes the reactant,
and the feed restores it between pulses. The overpotential is `electrode.eta` and the concentration
`electrode.c`.
Args:
eta:
The initial overpotential.
c:
The initial reactant concentration, relative to the feed.
C:
The capacitance of the double layer.
alpha:
The transfer coefficient.
tau:
The residence time of the reactor.
kappa:
The consumption of reactant per unit of Faradaic current.
current:
The current of a pulse.
period:
The time between the starts of pulses.
width:
The duration of a pulse.
label:
The label of the system, which names it when it is nested in another one.
solver:
The solver of the problem, or `'auto'` for the one the system chooses.
backend:
The backend that evaluates the compiled functions, or `'auto'` for the one the system chooses.
Examples:
>>> from skcomplex.systems.chemistry.kinetics import PulsedElectrochemicalReactorSystem
>>> PulsedElectrochemicalReactorSystem(width=1.0).prepare().system_.interactions[0].width
1.0
>>> sorted(PulsedElectrochemicalReactorSystem().get_tags().laws)
['rate']
"""
field = 'chemistry/kinetics'
topics = ('ode', 'electrochemistry', 'pulses', 'driven')
references = ('Trzaska 2023', 'Bard and Faulkner 2001')
until = 60.0
dt = 0.1
def __init__(
self,
eta: float = 0.0,
c: float = 1.0,
*,
C: float = 1.0,
alpha: float = 0.5,
tau: float = 10.0,
kappa: float = 0.05,
current: float = 5.0,
period: float = 10.0,
width: float = 2.0,
label: str = 'system',
solver: BaseSolver | str = 'auto',
backend: BaseBackend | str = 'auto',
) -> None:
super().__init__(label, solver=solver, backend=backend)
self.eta = eta
self.c = c
self.C = C
self.alpha = alpha
self.tau = tau
self.kappa = kappa
self.current = current
self.period = period
self.width = width
def _prepare(self, context: Sequence[Observable] | None = None) -> None:
"""Set `system_` to the electrode and the kinetics that charge the double layer and balance the reactant."""
super()._prepare(context)
kinetics = ElectrodeKineticsInteraction(
'kinetics',
target='electrode',
C=self.C,
alpha=self.alpha,
tau=self.tau,
kappa=self.kappa,
current=self.current,
period=self.period,
width=self.width,
)
electrode = PulsedElectrodeElement('electrode', eta=self.eta, c=self.c)
self.system_ = System(self.label, elements=[electrode], interactions=[kinetics])
Components
The system uses these element and interaction classes, each with its nearest class of the core.
Elements:
PulsedElectrodeElement, fromElement
Interactions:
ElectrodeKineticsInteraction, fromInteraction
class PulsedElectrodeElement(Element):
"""Electrode of a stirred electrochemical reactor, with its overpotential `eta` and reactant concentration `c`.
The electrode kinetics of `PulsedElectrochemicalReactorSystem` change both.
Args:
label:
The label of the electrode.
eta:
The initial overpotential.
c:
The initial reactant concentration, relative to the feed.
Examples:
>>> from skcomplex.systems.chemistry.kinetics import PulsedElectrodeElement
>>> PulsedElectrodeElement('electrode', c=0.5).c
0.5
"""
def __init__(
self,
label: str,
*,
eta: float = 0.0,
c: Annotated[float, RealSet.closed_open(0, oo)] = 1.0,
) -> None:
super().__init__(label)
self.eta = eta
self.c = c
class ElectrodeKineticsInteraction(Interaction):
"""Kinetics of an electrode that a train of current pulses charges.
In units of the exchange current and of the thermal voltage, the overpotential follows
`C deta/dt = i(t) - i_F`, with the Butler-Volmer current `i_F = c exp(alpha eta) - exp(-(1 - alpha) eta)`, and the
reactant concentration follows `dc/dt = (1 - c) / tau - kappa i_F`.
Args:
label:
The label of the interaction.
target:
The path of the electrode.
C:
The capacitance of the double layer.
alpha:
The transfer coefficient.
tau:
The residence time of the reactor.
kappa:
The consumption of reactant per unit of Faradaic current.
current:
The current of a pulse.
period:
The time between the starts of pulses.
width:
The duration of a pulse.
Examples:
>>> from skcomplex.systems.chemistry.kinetics import ElectrodeKineticsInteraction
>>> ElectrodeKineticsInteraction('kinetics', target='electrode').period
10.0
"""
law_classes: ClassVar[tuple[type[BaseLaw], ...]] = (RateLaw,)
def __init__(
self,
label: str,
*,
target: Role,
C: Annotated[float, RealSet.open(0, oo)] = 1.0,
alpha: Annotated[float, RealSet.open(0, oo)] = 0.5,
tau: Annotated[float, RealSet.open(0, oo)] = 10.0,
kappa: Annotated[float, RealSet.closed_open(0, oo)] = 0.05,
current: float = 5.0,
period: float = 10.0,
width: float = 2.0,
) -> None:
super().__init__(label)
self.target = target
self.C = C
self.alpha = alpha
self.tau = tau
self.kappa = kappa
self.current = current
self.period = period
self.width = width
def _prepare(self, context: SimpleNamespace) -> None:
"""Set the charging of the double layer and the balance of the reactant.
Args:
context:
The namespace of the electrode.
"""
super()._prepare(context)
s, eta, c = context, context.target.eta, context.target.c
faradaic = c * exp(s.alpha * eta) - exp(-(1 - s.alpha) * eta)
applied = s.current * pulse_train(s.t, self.period, self.width)
self.laws_: list[BaseLaw] = [
RateLaw(eta.diff(s.t), (applied - faradaic) / s.C),
RateLaw(c.diff(s.t), (1 - c) / s.tau - s.kappa * faradaic),
]
Equations
The equations are those that symbolic returns for the system with its default parameters.
electrode.eta: diff(eta_electrode(t), t) == -(c_electrode(t)*e^(alpha_kinetics*eta_electrode(t)) - current_kinetics*where(both(t >= 0.0, mod(t, 10.0) < 2.0), 1.0, 0) - e^((alpha_kinetics - 1)*eta_electrode(t)))/C_kinetics
electrode.c: diff(c_electrode(t), t) == -(c_electrode(t)*e^(alpha_kinetics*eta_electrode(t)) - e^((alpha_kinetics - 1)*eta_electrode(t)))*kappa_kinetics - (c_electrode(t) - 1)/tau_kinetics