.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/ode_dynamics/limit_cycles/plot_03_brusselator_hopf.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_ode_dynamics_limit_cycles_plot_03_brusselator_hopf.py: The Brusselator's Hopf bifurcation ======================================== The Brusselator's fixed point :math:`(a, b/a)` is stable until :math:`b` crosses :math:`b_c = 1 + a^2`, where the trace of its Jacobian changes sign and a limit cycle is born: the model chemical reaction starts to oscillate. .. GENERATED FROM PYTHON SOURCE LINES 12-21 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from mathematicskit.ode_dynamics.systems.chemical_oscillators import Brusselator, brusselator_hopf_threshold a = 1.0 b_c = brusselator_hopf_threshold(a) print(f"Hopf threshold b_c = 1 + a^2 = {b_c}") .. rst-class:: sphx-glr-script-out .. code-block:: none Hopf threshold b_c = 1 + a^2 = 2.0 .. GENERATED FROM PYTHON SOURCE LINES 22-24 Below and above the threshold ----------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 24-34 .. code-block:: Python fig, axes = plt.subplots(1, 2, figsize=(11, 4.5)) for b in (1.7, 3.0): traj = Brusselator([1.2, 1.0], a=a, b=b).integrate((0.0, 60.0), dt=1e-2, method="rk4") axes[0].plot(traj.y[:, 0], traj.y[:, 1], lw=1, label=f"b={b}") axes[0].set_xlabel("x") axes[0].set_ylabel("y") axes[0].set_title("Spiral into the fixed point vs. limit cycle") axes[0].legend() .. image-sg:: /api/gallery/ode_dynamics/limit_cycles/images/sphx_glr_plot_03_brusselator_hopf_001.png :alt: Spiral into the fixed point vs. limit cycle :srcset: /api/gallery/ode_dynamics/limit_cycles/images/sphx_glr_plot_03_brusselator_hopf_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 35-37 Oscillation amplitude across the bifurcation -------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 37-52 .. code-block:: Python bs = np.linspace(1.5, 3.5, 21) amps = [] for b in bs: traj = Brusselator([1.2, 1.0], a=a, b=b).integrate((0.0, 300.0), dt=1e-2, method="rk4") amps.append(np.ptp(traj.y[-5000:, 0])) axes[1].plot(bs, amps, "o-") axes[1].axvline(b_c, color="gray", ls="--", label="b_c = 1 + a^2") axes[1].set_xlabel("b") axes[1].set_ylabel("peak-to-peak x") axes[1].set_title("Oscillations switch on at b_c") axes[1].legend() fig.tight_layout() plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 5.034 seconds) .. _sphx_glr_download_api_gallery_ode_dynamics_limit_cycles_plot_03_brusselator_hopf.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_03_brusselator_hopf.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_03_brusselator_hopf.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_03_brusselator_hopf.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_