.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/kinetics/networks/plot_05_parallel_reactions.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_networks_plot_05_parallel_reactions.py: Parallel (competing) first-order reactions ============================================ For two competing channels :math:`A \xrightarrow{k_1} B` and :math:`A \xrightarrow{k_2} C`, the reactant decays with the *sum* :math:`k_1 + k_2`, while the product ratio :math:`[B]/[C] = k_1/k_2` is fixed at every instant -- the kinetic basis of product selectivity. Integrated with :meth:`~chemistrykit.kinetics.systems.networks.StoichiometricNetwork.parallel`. .. GENERATED FROM PYTHON SOURCE LINES 14-32 .. image-sg:: /api/gallery/kinetics/networks/images/sphx_glr_plot_05_parallel_reactions_001.png :alt: Parallel channels: final [B]/[C] = 4.000 (k1/k2 = 4) :srcset: /api/gallery/kinetics/networks/images/sphx_glr_plot_05_parallel_reactions_001.png :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from chemistrykit.kinetics.systems.networks import StoichiometricNetwork from chemistrykit.kinetics.visualizers.kinetics_plots import plot_concentration_vs_time k1, k2 = 2.0, 0.5 net = StoichiometricNetwork.parallel(k1=k1, k2=k2, A0=1.0) result = net.integrate((0.0, 4.0), dt=1e-3, method="rk4") fig, ax = plt.subplots(figsize=(7, 5)) plot_concentration_vs_time(result, ax=ax) ax.plot(result.t, np.exp(-(k1 + k2) * result.t), "k--", linewidth=0.8, label="exp(-(k1+k2)t)") ax.legend() ratio = result.concentration("B")[-1] / result.concentration("C")[-1] ax.set_title(f"Parallel channels: final [B]/[C] = {ratio:.3f} (k1/k2 = {k1 / k2:g})") fig.tight_layout() plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.330 seconds) .. _sphx_glr_download_api_gallery_kinetics_networks_plot_05_parallel_reactions.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_05_parallel_reactions.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_05_parallel_reactions.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_05_parallel_reactions.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_