.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/kinetics/arrhenius/plot_01_arrhenius_fit.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_kinetics_arrhenius_plot_01_arrhenius_fit.py: Recovering an activation energy from an Arrhenius plot ========================================================= Synthetic rate-constant-vs-temperature data is generated from a known activation energy :math:`E_a` and pre-exponential factor :math:`A`, then :func:`~chemistrykit.kinetics.systems.arrhenius.fit_arrhenius` recovers both parameters back out via the classic Arrhenius-plot linearization (:math:`\ln k` vs. :math:`1/T`). .. GENERATED FROM PYTHON SOURCE LINES 13-31 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from chemistrykit.kinetics.systems.arrhenius import arrhenius_rate_constant, fit_arrhenius from chemistrykit.kinetics.visualizers.kinetics_plots import plot_arrhenius A_true, Ea_true = 4.2e12, 65_000.0 # J/mol T = np.linspace(280.0, 360.0, 9) rng = np.random.default_rng(0) k_exact = arrhenius_rate_constant(A=A_true, Ea=Ea_true, T=T) # A small amount of multiplicative noise, as a real kinetics measurement would have. k_noisy = k_exact * (1.0 + rng.normal(0.0, 0.02, size=T.shape)) fit = fit_arrhenius(T, k_noisy) print(f"true: Ea={Ea_true:.0f} J/mol, A={A_true:.3e}") print(f"fitted: Ea={fit.Ea:.0f} J/mol, A={fit.A:.3e}, R^2={fit.r_squared:.5f}") .. rst-class:: sphx-glr-script-out .. code-block:: none true: Ea=65000 J/mol, A=4.200e+12 fitted: Ea=65046 J/mol, A=4.293e+12, R^2=0.99996 .. GENERATED FROM PYTHON SOURCE LINES 32-33 The Arrhenius plot: a straight line of slope :math:`-E_a/R`. .. GENERATED FROM PYTHON SOURCE LINES 33-38 .. code-block:: Python ax = plot_arrhenius(T, k_noisy, fit=fit) ax.set_title(f"Arrhenius plot (fitted Ea = {fit.Ea / 1000:.1f} kJ/mol)") plt.tight_layout() plt.show() .. image-sg:: /api/gallery/kinetics/arrhenius/images/sphx_glr_plot_01_arrhenius_fit_001.png :alt: Arrhenius plot (fitted Ea = 65.0 kJ/mol) :srcset: /api/gallery/kinetics/arrhenius/images/sphx_glr_plot_01_arrhenius_fit_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.038 seconds) .. _sphx_glr_download_api_gallery_kinetics_arrhenius_plot_01_arrhenius_fit.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_arrhenius_fit.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_arrhenius_fit.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_arrhenius_fit.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_