.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/chaos/maps/plot_circle_map_arnold_tongues.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_chaos_maps_plot_circle_map_arnold_tongues.py: Circle map: Arnold tongues of mode locking ========================================== The sine circle map .. math:: \theta_{n+1} = \theta_n + \Omega - \frac{K}{2\pi}\sin(2\pi\theta_n) is the simplest model of a nonlinear oscillator driven at a second frequency. :math:`\Omega` is the ratio of the two bare frequencies, and the winding number :math:`W = \lim(\theta_n - \theta_0)/n` is the ratio the system actually shows. At :math:`K = 0` the map is a rigid rotation and :math:`W = \Omega`. Arnold (1961) showed that any coupling locks every rational :math:`W = p/q` over a whole interval of :math:`\Omega`. In the :math:`(\Omega, K)` plane these intervals grow out of the points :math:`\Omega = p/q` on the :math:`K = 0` axis as tongues, and the tongue of period :math:`q` starts with a width proportional to :math:`K^q`. The main tongue (:math:`W = 0`) has the exact edges :math:`\Omega = \pm K/(2\pi)`. .. GENERATED FROM PYTHON SOURCE LINES 22-30 .. code-block:: Python from math import gcd import matplotlib.pyplot as plt import numpy as np from physicskit.chaos.systems.maps import CircleMap, mode_locking_interval, winding_number .. GENERATED FROM PYTHON SOURCE LINES 31-39 The tongues in the (Omega, K) plane ----------------------------------- Each band is computed by :func:`~physicskit.chaos.systems.maps.mode_locking_interval`, which finds the two saddle-node edges where the :math:`p/q` periodic orbit is born and dies. At :math:`K = 1` the tongues of all periods together fill the :math:`\Omega` axis, apart from a set of measure zero. .. GENERATED FROM PYTHON SOURCE LINES 39-57 .. code-block:: Python K_grid = np.linspace(0.0, 1.0, 41) fractions = [(p, q) for q in range(1, 7) for p in range(q + 1) if gcd(p, q) == 1] fig, axes = plt.subplots(1, 2, figsize=(12, 5)) for p, q in fractions: edges = np.array([mode_locking_interval(p, q, K) for K in K_grid]) axes[0].fill_betweenx(K_grid, edges[:, 0], edges[:, 1], color=plt.cm.viridis(q / 7), alpha=0.85, lw=0) if q <= 4: axes[0].annotate(f"{p}/{q}", (p / q, 1.0), ha="center", va="bottom", fontsize=8) axes[0].plot(K_grid / (2 * np.pi), K_grid, "r--", lw=1, label=r"$\Omega = \pm K/2\pi$") axes[0].plot(-K_grid / (2 * np.pi), K_grid, "r--", lw=1) axes[0].set_xlim(0, 1) axes[0].set_ylim(0, 1.06) axes[0].set_xlabel(r"$\Omega$") axes[0].set_ylabel("K") axes[0].set_title(r"Arnold tongues of the circle map, $q \leq 6$") axes[0].legend(loc="lower left", fontsize=8) .. image-sg:: /api/gallery/chaos/maps/images/sphx_glr_plot_circle_map_arnold_tongues_001.png :alt: Arnold tongues of the circle map, $q \leq 6$ :srcset: /api/gallery/chaos/maps/images/sphx_glr_plot_circle_map_arnold_tongues_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 58-64 How the tongues open -------------------- Near :math:`K = 0` a :math:`p/q` orbit only feels the :math:`q`-th harmonic of the forcing, which first appears at order :math:`K^q`, so the tongue widths grow as :math:`K^q`. .. GENERATED FROM PYTHON SOURCE LINES 64-75 .. code-block:: Python K_small = np.logspace(-1.3, -0.5, 6) for p, q in [(0, 1), (1, 2), (1, 3), (1, 4)]: w = [np.subtract(*mode_locking_interval(p, q, K)[::-1]) for K in K_small] axes[1].loglog(K_small, w, "o-", label=rf"$W = {p}/{q}$") axes[1].set_xlabel("K") axes[1].set_ylabel("tongue width in $\\Omega$") axes[1].set_title(r"Widths grow as $K^q$") axes[1].legend(fontsize=8) fig.tight_layout() .. GENERATED FROM PYTHON SOURCE LINES 76-82 Locked and quasiperiodic orbits ------------------------------- Inside the 2/5 tongue the orbit settles onto five points of the circle. Just outside it, at an irrational-looking :math:`W`, the orbit fills the circle densely. .. GENERATED FROM PYTHON SOURCE LINES 82-93 .. code-block:: Python K = 0.8 lo, hi = mode_locking_interval(2, 5, K) fig2, ax2 = plt.subplots(figsize=(6, 6), subplot_kw={"aspect": "equal"}) for Omega, color, label in [(0.5 * (lo + hi), "C3", "locked, W = 2/5"), (hi + 0.02, "C0", "quasiperiodic")]: theta = CircleMap(K, Omega).trajectory(n_iter=600)[100:, 0] % 1.0 ax2.plot(np.cos(2 * np.pi * theta), np.sin(2 * np.pi * theta), ".", color=color, ms=6 if color == "C3" else 2, label=label) ax2.set_title(f"Orbits on the circle, K = {K}") ax2.legend(loc="center", fontsize=8) ax2.set_axis_off() .. image-sg:: /api/gallery/chaos/maps/images/sphx_glr_plot_circle_map_arnold_tongues_002.png :alt: Orbits on the circle, K = 0.8 :srcset: /api/gallery/chaos/maps/images/sphx_glr_plot_circle_map_arnold_tongues_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 94-99 Check ----- W = Omega at K = 0. The main tongue's edges are Omega = +-K/(2 pi). The 1/2 and 1/3 tongues open as K^2 and K^3 (log-log slopes 2 and 3). Inside the 2/5 tongue W = 2/5. .. GENERATED FROM PYTHON SOURCE LINES 99-108 .. code-block:: Python Omega = np.linspace(0, 1, 11) assert np.allclose(winding_number(0.0, Omega), Omega, atol=1e-12) for K in (0.25, 0.5, 1.0): lo0, hi0 = mode_locking_interval(0, 1, K) assert abs(hi0 - K / (2 * np.pi)) < 1e-9 and abs(lo0 + K / (2 * np.pi)) < 1e-9 for p, q in [(1, 2), (1, 3)]: w = [np.subtract(*mode_locking_interval(p, q, K)[::-1]) for K in K_small] assert abs(np.polyfit(np.log(K_small), np.log(w), 1)[0] - q) < 0.1 assert abs(winding_number(0.8, 0.5 * (lo + hi), n_iter=20000) - 0.4) < 1e-4 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.876 seconds) .. _sphx_glr_download_api_gallery_chaos_maps_plot_circle_map_arnold_tongues.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_circle_map_arnold_tongues.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_circle_map_arnold_tongues.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_circle_map_arnold_tongues.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_