.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/electrochem/voltammetry/plot_01_cottrell_equation.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_api_gallery_electrochem_voltammetry_plot_01_cottrell_equation.py: The Cottrell equation: current decay after a potential step ============================================================= Cottrell (1903) solved the diffusion problem for a planar electrode whose potential is suddenly stepped so that the electroactive species is consumed at the surface: the current decays as :math:`t^{-1/2}`, :math:`i = nFAC\sqrt{D/(\pi t)}`. This example plots :func:`~chemistrykit.electrochem.systems.voltammetry.cottrell_current`, checks the constant :math:`i\sqrt{t}` signature, and recovers the diffusion coefficient from a noisy "measured" transient via the Cottrell plot of :math:`i` against :math:`t^{-1/2}`. .. GENERATED FROM PYTHON SOURCE LINES 16-29 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from chemistrykit.constants import FARADAY from chemistrykit.electrochem.systems.voltammetry import cottrell_current n, A, C, D_true = 1, 7.07e-6, 1.0, 7.0e-10 # 3 mm disc, 1 mM, D in m^2/s t = np.linspace(0.05, 5.0, 80) i_true = cottrell_current(t, n, A, C, D_true) print( f"i*sqrt(t) at t = 0.1 s and 4 s: {cottrell_current(0.1, n, A, C, D_true) * np.sqrt(0.1):.4e}, {cottrell_current(4.0, n, A, C, D_true) * 2.0:.4e} A s^1/2" ) .. rst-class:: sphx-glr-script-out .. code-block:: none i*sqrt(t) at t = 0.1 s and 4 s: 1.0183e-05, 1.0183e-05 A s^1/2 .. GENERATED FROM PYTHON SOURCE LINES 30-32 Cottrell plot: i vs t^-1/2 is a line through the origin with slope nFAC sqrt(D/pi). .. GENERATED FROM PYTHON SOURCE LINES 32-52 .. code-block:: Python rng = np.random.default_rng(1903) i_meas = i_true * (1 + rng.normal(0.0, 0.01, t.size)) slope = np.sum(i_meas * t**-0.5) / np.sum(t**-1.0) D_fit = np.pi * (slope / (n * FARADAY * A * C)) ** 2 print(f"D true = {D_true:.2e} m^2/s, D from Cottrell plot = {D_fit:.2e} m^2/s") fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(10, 4)) ax1.plot(t, i_meas * 1e6, ".", label="measured") ax1.plot(t, i_true * 1e6, label="Cottrell") ax1.set_xlabel("t (s)") ax1.set_ylabel(r"i ($\mu$A)") ax1.set_title(r"$t^{-1/2}$ decay after a potential step") ax1.legend() ax2.plot(t**-0.5, i_meas * 1e6, ".") ax2.plot(t**-0.5, slope * t**-0.5 * 1e6) ax2.set_xlabel(r"$t^{-1/2}$ (s$^{-1/2}$)") ax2.set_ylabel(r"i ($\mu$A)") ax2.set_title("Cottrell plot") fig.tight_layout() plt.show() .. image-sg:: /api/gallery/electrochem/voltammetry/images/sphx_glr_plot_01_cottrell_equation_001.png :alt: $t^{-1/2}$ decay after a potential step, Cottrell plot :srcset: /api/gallery/electrochem/voltammetry/images/sphx_glr_plot_01_cottrell_equation_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none D true = 7.00e-10 m^2/s, D from Cottrell plot = 7.00e-10 m^2/s .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.053 seconds) .. _sphx_glr_download_api_gallery_electrochem_voltammetry_plot_01_cottrell_equation.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_01_cottrell_equation.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_cottrell_equation.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_cottrell_equation.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_