electrochemistry: calculations relevant in electrochemistry

Code author: Peter Kraus

Includes functions for calculating applied voltage correction via the nernst() equation, calculation of the Faradaic efficiency (fe()), as well as the calculation of total charge(), and the average_current() from the total charge and timestamps.

Functions

average_current(time, Q[, t0, output])

Calculate the average current \(<I>\) from a set of timestamped values of electical charge,

charge(time, I[, t0, output])

Calculate the total charge \(Q\) as a time-integral of the electric current:

fe(rate, I, charges[, output])

Calculate the Faradaic efficiency \(\eta_F\) from a set of molar rates \(\dot{n}`\) corresponding to a single mixture, and the applied current \(I\) required to produce that mixture from a source mixture.

nernst(Ewe[, R, I, Eref, T, n, Q, pH, output])

Correct measured voltage to calculate the applied voltage, using corrections for Ohmic drop, reference potential vs RHE, and ionic concentration using the Nernst equation, either by providing \(Q\) and \(n\), or by providing the \(pH\).

dgpost.transform.electrochemistry.nernst(Ewe: ~pint.registry.Quantity, R: ~pint.registry.Quantity = <Quantity(0.0, 'ohm')>, I: ~pint.registry.Quantity = <Quantity(0.0, 'ampere')>, Eref: ~pint.registry.Quantity = <Quantity(0.0, 'volt')>, T: ~pint.registry.Quantity = <Quantity(298.15, 'kelvin')>, n: int = None, Q: float = None, pH: float = None, output: str = 'Eapp') Quantity

Correct measured voltage to calculate the applied voltage, using corrections for Ohmic drop, reference potential vs RHE, and ionic concentration using the Nernst equation, either by providing \(Q\) and \(n\), or by providing the \(pH\).

This function corrects the measured voltage \(E_\text{we}\) to applied voltage \(E\). For \(E_\text{we} > 0~\text{V}\), the following equation is used:

\[\begin{split}E &= E_\text{we} - R |I| + E_\text{ref} + E_N \\ E_N &= - \frac{\overline{R} T}{nF} ln(Q) = \frac{\overline{R} T}{F} ln(10) \text{pH}\end{split}\]

where \(R |I|\) is the product of cell resistance and the magnitude of the applied current, \(E_\text{ref}\) is the potential of the reference electrode vs RHE, \(\overline{R}\) is the molar gas constant, \(T\) is the temperature, \(n\) is the number of electrones transferred, \(F\) is the Faraday constant, \(Q\) is the reaction quotient, and \(\text{pH}\) is the pH of the electrolyte.

Note

The Ohmic loss \(R |I|\) always acts against the magnitude of the working potential \(E_\text{we}\). If \(E_\text{we} < 0~\text{V}\), the Ohmic term \(R |I|\) is added to \(E_\text{we}\) to reduce its magnitude.

Parameters:
  • Ewe – The measured working potential with respect to the reference electrode. By default in V.

  • R – The resistance of the cell. By default in Ω.

  • I – The applied current. By default in A.

  • Eref – The potential of the reference electrode with respect to RHE. By default in V.

  • T – Temperature of the working electrode, used in the Nernst equation. By default 298.15 K.

  • n – Number of electrons transferred in the process described by the Nernst equation. Must be specified along Q, cannot be specified with pH.

  • Q – The reaction quotient of the components of the process described by the Nernst equation. Must be specified along n, cannot be specified with pH.

  • pH – The pH of the solution. This assumes the modelled process is the reduction of \(\text{H}^+ \rightarrow \text{H}`\), i.e. \(n = 1\) and \(\text{ln}(Q) = -\text{ln}(10)\text{pH}\)

  • output – Name of the output variable. Defaults to Eapp.

Returns:

dict(output, E) – Returns the calculated applied current in V.

Return type:

dict[str, pint.Quantity]

dgpost.transform.electrochemistry.fe(rate: dict[str, Quantity], I: Quantity, charges: dict[str, int], output: str = None) dict[str, Quantity]

Calculate the Faradaic efficiency \(\eta_F\) from a set of molar rates \(\dot{n}`\) corresponding to a single mixture, and the applied current \(I\) required to produce that mixture from a source mixture. A set of formal atomic charges corresponding to those in the species comprising the source mixture has to be supplied.

This function implements the following equation to calculate \(\eta_F\):

\[\eta_F(x) = \frac{n_\text{el}(x)\dot{n}(x)}{I}\]

where \(x\) is a species in the mixture, \(n_\text{el}(x)\) is the number of electrons required to produce \(x\) from the ions specified in the source mixture, and \(\dot{n}(x)\) is the molar rate (production or flow) of species \(x\).

Parameters:
  • rate – A dict of molar flow or production rates of species in a mixture. By default in mol/l.

  • I – The applied current. By default in A.

  • charges – A dict of formal atomic/ionic charges of atoms in the source mixture.

  • output – Name of the prefix for the species in the output variable. Defaults to fe.

Returns:

dict(output, E) – Returns the calculated Faradaic efficiencies.

Return type:

dict[str, pint.Quantity]

dgpost.transform.electrochemistry.charge(time: Quantity, I: Quantity, t0: Quantity = None, output: str = 'Q') dict[str, Quantity]

Calculate the total charge \(Q\) as a time-integral of the electric current:

\[Q_n = \int_{t_0}^{t_n} I(t) dt = \sum_0^n I_n (t_n - t_{n-1})\]

where \(I_n\) is the instantaneous current and \(t_n\) is the time at the \(n\)-th datapoint.

Parameters:
  • time – An array of timestamps at which the instantaneous current was measured. Defaults to the pd.Index of the pd.DataFrame.

  • I – Values of the instantaneous current.

  • t0 – An optional timestamp representing the time at which charge was zero. If not supplied, the first value in the time array will be used, with the charge at that timestamp set to zero.

  • output – Prefix of the columns where the calculated rate will be stored.

Returns:

dict(output, Q) – Returns the integrated electrical charge.

Return type:

dict[str, pint.Quantity]

dgpost.transform.electrochemistry.average_current(time: Quantity, Q: Quantity, t0: Quantity = None, output: str = '<I>') dict[str, Quantity]

Calculate the average current \(<I>\) from a set of timestamped values of electical charge,

\[<I> = \frac{dQ}{dt} = \frac{Q_n - Q_{n-1}}{t_n - t_{n-1}}\]

where \(Q_n\) is the charge and \(t_n\) is the time at the \(n\)-th datapoint.

Parameters:
  • time – An array of timestamps at which the instantaneous current was measured. Defaults to the pd.Index of the pd.DataFrame.

  • Q – Values of the overall charge.

  • t0 – An optional timestamp representing the time at which charge was zero. If not supplied, the first value in the time array will be used, with the charge at that timestamp set to zero.

  • output – Prefix of the columns where the calculated rate will be stored.

Returns:

dict(output, I) – Returns the average electrical current.

Return type:

dict[str, pint.Quantity]